Tag Archives: XYZ

How to exit a script with error ?

By Salil Gupta

Hi,

I have a script ABC which calls another script XYZ. Function of XYZ is to ftp a file from one server to another.

code for ABC:

Code:

#!/bin/ksh
PATH=/usr/bin

home/user/xyz "$@"

exit $?
~


code for xyz:

Code:

#!/bin/ksh
HOSTNAME=$1
SRCNAME=$2
DSTNAME=$3

### This file holds the outget of the FTP commands for success checking
FTPCHK=/tmp/ftpchk.$$
#touch $FTPCHK
echo "" > $FTPCHK

SRCFILE=$SRCNAME

DSTFILE=$DSTNAME

echo Source Host: $HOSTNAME
echo Source File Name: $SRCFILE
echo Destination File: $DSTFILE

echo `date` Beginning FTP download...
ftp -v ${HOSTNAME} <>$FTPCHK 2>&1
ascii
nlist ${SRCFILE}
get ${SRCFILE} ${DSTFILE}
quit
EOF

### Check for FTP errors
CHK1=`grep -c "226 Transfer complete." $FTPCHK`
CHK2=`grep -c "226 ASCII Transfer complete." $FTPCHK`
CHK3=`grep -ic "226 transfer complete" $FTPCHK`
CHK4=`grep -ic "226 File send OK." $FTPCHK`

### In NT, There should transmissions complete:
### One for the data transfer,
### One for the nlist

if [ $CHK1 -eq 2 ] || [ $CHK2 -eq 2 ] || [ $CHK1 -eq 1 -a $CHK2 -eq 1 ] || [ $CHK3 -eq 2 ] || [ $CHK4 -eq 1 ]; then
RC=0
echo "OK: FTP Transmission Worked"
echo '--------------------------------------------------------------'
cat $FTPCHK
echo '--------------------------------------------------------------'

else
RC=1
echo "ERROR: FTP Transmission Failed"
banner "ERROR"
echo '--------------------------------------------------------------'
cat $FTPCHK
echo '--------------------------------------------------------------'
fi

date
ls -al ${DSTFILE}

rm $FTPCHK

echo '---------------------------------------------------------------------'

exit $RC


In script XYZ, I am trying to ftp a file. So during ftp , whenever it shows that space is less than size of file, it should ftp the partial according to the available space and prompt a message about it and also prompt a message to outer script that inner script could not complete successfully. Hence resulting in the failure of outer script, due to partial ftp of file.

Also please post the comments about the each step of script to explain what is happening in that step. Thanks a lot in advance.

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

SFTP GET Local folder issue

By skpvalvekar

Hi,
I’m facing the following strange issue with SFTP execution. I need to copy a file ‘abc.txt’ from Remote m/c(MyServer) to local machine(Server1). I’ve this file in the folder /users/XYZ on MyServer and need to SFTP it to /users/ABCD on Server1.

On Server1:
————————-
cd /users/XYZ
> ls TEST
>TEST/ /* TEST is a sub dir in /users/XYZ */

>ls abc.txt
> /* ls returns no thing as the file doesnot exists here and I need to get it to a folder TEST under this dir */

>sftp uname/pwd@MyServer
> ls /users/ABCD/abc.txt
abc.txt /* File exists*/
> get /users/ABCD/abc.txt /users/XYZ/TEST/abc.txt
sys err:
>bye

On Server1:
——-
>ls /users/XYZ/TEST/abc.txt
>/* returns no file with such a name
>ls /users/XYZ/abc.txt
>abc.txt /*File got copied here as I exected SFTP command from here*/

When I execute this, my intention was to get the file ‘abc.txt’ on to ‘/users/XYZ/TEST‘, but the execution seems to be a fail, but the catch is that the file gets copied to /users/XYZ, but not to my intended location.
When I’m in /users/XYZ/TEST and When I give “get /users/ABCD/abc.txt” through SFTP without local path details with out any error, the file gets placed in /users/XYZ/TEST.

My requirement is that I should execute SFTP from /users/XYZ dir and get the file on to /users/XYZ/TEST folder with out the sys error.

Your help is highly appreciated.

Regards,
SKP

From: http://www.unix.com/shell-programming-scripting/221277-sftp-get-local-folder-issue.html

UK National Graphene Institute Selects Bruker's Dimension FastScan AFM

By Business Wirevia The Motley Fool

Filed under:

UK National Graphene Institute Selects Bruker’s Dimension FastScan AFM

New Levels of Speed, Ease of Use, and Productivity Enable Next-Generation Applications

SANTA BARBARA, Calif.–(BUSINESS WIRE)– Bruker has established a collaborative partnership with the University of Manchester’s new National Graphene Institute (NGI) to leverage the benchmark speed, resolution and performance of the Dimension FastScan® Atomic Force Microscope (AFM) for research into the nanofabrication and nanoscale properties of graphene.

Graphene, the world’s thinnest, strongest and most conductive material, was first isolated and characterized at The University of Manchester by Professor Andre Geim and Professor Kostya Novoselov, who were awarded the Nobel Prize for Physics in 2010 for their research. This transparent, one-atom thick flat sheet of carbon has the potential to revolutionize technology, from smartphones and ultrafast broadband to drug delivery and computer chips. Bruker’s unique PeakForce TUNATM and PeakForce KPFMTM nanoelectrical AFM modes are anticipated to provide important new insights into nanoscale variations of graphene conductivity and work function. Coupled with simultaneous quantitative mapping of mechanical properties enabled by Bruker’s exclusive PeakForce QNM® AFM mode, NGI researchers hope to uncover new information that will ultimately optimize the performance of new graphene-based materials and devices.

“Bruker’s Dimension FastScan provides our team with the best available technology to support the complex demands for sub-nanometer observations of graphene,” said Nobel Prize winner Professor Novoselov. “The unmatched speed and unique property mapping modes of FastScan will benefit many researchers across our institute and its partners. One of our key goals is to benefit from collaborative partnerships with leading global industry innovators, and we are very much looking forward to partnering with Bruker’s team of AFM innovators and application scientists.”

“It is clear that the world-class research team at The University of Manchester and its National Graphene Institute is a leader in graphene research and we are delighted that they have selected Bruker AFM systems to enable their work,” added David V. Rossi, Executive Vice President and General Manager of Bruker’s AFM Business. “It is also pleasing to see that the Dimension FastScan and Bruker’s new proprietary nanoelectrical AFM modes are being used to accelerate graphene research and its technological applications.”

About Dimension FastScan

The Dimension FastScan system utilizes a revolutionary XYZ closed-loop head that scans at high-speed rates while delivering extremely low drift and low noise to make atomic force microscopy easier …read more
Source: FULL ARTICLE at DailyFinance

Batch Script To Unzip and Rename File

By rajlakshmi

Hello All,

I need help in writing a batch script.

I have 100 zip files in a folder. Each zip file has a unique name starting with XYZ_12345.zip Each zip file contains single csv file

I would like to batch extract the files and also rename the extracted csv as per the original zip name (only the text name as in XYZ and not the XYZ_12345)

Can someone please help with this script. I would be extremely grateful for the help.

Many thanks in anticipation.

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Grep a line

i would like to grep a particular line form several file which is within the folder
for example i have folder like 2010a, 2010b 2010c…. and each folder there is file with post1, post2 and post3…
from each file there is line
XYZ 10 10 10.
XYZ 21 31 30
so i want to grep XYZ and its related column.
can ayone help in writing the script.
Thanks in advance
Source: The UNIX and Linux Forums