Hello
I am trying to write a script that sends files via ftp from one server to another, i am using AIX 5.1. and bash shell to write my code.
I get an error when trying to run the following lines of code
ftp -n aptsbou01 <<!
user $username $password
binary
put $file
bye
!
I get the following error
ftptest.sh[7]: 0403-057 Syntax error at line 13 : `<' is not matched.
where line 13 is the first line in the code snippet above.
But i believe that is the correct syntax for this statement. I am unable to proceed further due to this error.
I would appreciate if anybody could help me in resolving this.
Thanks in advance
Swaraj
Hello
Doesnt anybody have a solution for this one, I am in urgent need of this please if anybody knows or can guide me to a link where i can find a solution that would be great.
Thanks
Swaraj:confused:
Well, I've got an ftp server running on one of my systems, and
ftp -n localhost <<!
blah
.
.
.
blah
!
Works fine for me in a bash script.
Can you post your *complete* script?
Actually, I think I know where your problem may be. Where you close the here document with "!", if it isn't in column 1 of the file (i.e. NO leading whitespace), then the here document will not be properly terminated.
Peace
ZB
Thanks a lot for responding
Here is my complete code
# search for files with .txt extension
(ls -la .txt | awk '{print $0, ","; }') > filelist.txt
chmod a+x filelist.txt
filenamelist=$(cat filelist.txt | awk '{print $9;}')
#server = "aptsbou01"
for file in $filenamelist; do
filename=${file##//}
if [[ -f $filename ]] ; then
echo $file
echo "Now transmitting each file via ftp"
echo "Connecting to ftp on another server"
ftp -n aptsbou01 <<!
user kankipas nodalMB8
binary
put $file
bye
!
fi
done
#echO $(#filenamelist[*])
Thanks
Swaraj
Hi ZB
I actually modified my script so that the code for the ftp session starts from column 1 and it worked.
Thanks a lot for the help.
Swaraj