Reputation: 55
Anyone can help me what will be the problem? login name and password is from .netrc. , < before example.script wont work
#!/bin/bash
HOST='192.163.3.3'
FILE="a.txt"
while :; do
ftp -p -v -i $HOST << example.script >> a.log
grep -qF "Connected" a.log &&
grep -qF "File successfully transferred" a.log && break
done
exit 0
example.script contains
put $FILE
quit
And the error is:
./example.sh: line 15: syntax error: unexpected end of file
I got this while I'm using sh -vx
on my script:
while :; do
ftp -p -v -i $HOST < example.script >> a.log
grep -qF "Connected" a.log &&
grep -qF "File successfully transferred" a.log && break
done
+ :
+ ftp -p -v -i 192.163.3.3
+ grep -qF Connected a.log
grep: a.log: No such file or directory
+ :
+ ftp -p -v -i 192.163.3.3
+ grep -qF Connected a.log
grep: a.log: No such file or directory
+ :
Note that this code fixes the problem (using <
instead of <<
for the input redirection). The script file is given as exaple.script
instead of example.script
.
Upvotes: 0
Views: 208
Reputation: 184995
You need to close your here-doc :
#!/bin/bash
HOST='192.163.3.3'
FILE="a.txt"
while :; do
ftp -p -v -i $HOST <<EOF example.script >> a.log
grep -qF "Connected" a.log &&
grep -qF "File successfully transferred" a.log && break
done
EOF
<<
open a here-doc
Upvotes: 0
Reputation: 46813
Change your here document <<
which has nothing to do here! Instead, you mean:
ftp -p -v -i $HOST < example.script >> a.log
Upvotes: 2