sunhux
asked on
value of variables in Shell script became null after sftp batch command : Urgent
I'm writing sftp Shell scripts (in -b batch mode) but seems like after
sftp codes, the value of the variables (in particular FILE_NAME )
was reset to null (or empty).
Attached the scripts, where scr1.sh will call scr2.sh
I've tried to export the variables (as shown in the script) but no joy.
I don't have this problem previously when this script was using 'ftp'
(but I'm now required to convert it to sftp)
The outputs I got after running "ksh -v scr1.sh " :
Couldn't stat remote file: No such file or directory
Couldn't delete file: No such file or directory
Invalid command.
Couldn't stat remote file: No such file or directory
Couldn't delete file: No such file or directory
-rw------- 1 root root 34 Oct 5 11:56 /appl/career/dataload/in/s
/appl/career/dataload/in/.
dos2unix: converting file /appl/career/dataload/in/.
dos2unix: problems converting file /appl/career/dataload/in/.
I'm on RHES 4.6
sftpVarnullScr3.txt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hurray, both yr suggestions works
ASKER
> is designed to process multiple files (otherwise you wouldn't need the "for FILENAME"
> loops at all. This means that $3 passed into scr2.sh may have spaces in it
Yes, that's right; it may have multiple files separated by a space between the files.
But I thought scr1.sh already has double quotes when passing to scr2,sh ie
"sftp_xxo_acknowledge1.dat
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
excellent
ASKER
Thanks, will try that in a moment when I reached office.
Btw, is the syntax echo "-quit" Ok?
[
...
echo "-quit"
} sftp -b ...