[SLE] Bash script: problem in using ftp -n $server <<End-Of-Session in a while loop
From: Gaël Lams (lamsgael_at_gmail.com)
Date: 09/29/05
- Previous message: Ronald Wiplinger: "[SLE] mysql client server, sock miss-match"
- Next in thread: Ulf Rasch: "Re: [SLE] Bash script: problem in using ftp -n $server <<End-Of-Session in a while loop"
- Reply: Ulf Rasch: "Re: [SLE] Bash script: problem in using ftp -n $server <<End-Of-Session in a while loop"
- Reply: Scott Leighton: "Re: [SLE] Bash script: problem in using ftp -n $server <<End-Of-Session in a while loop"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Sep 2005 12:01:49 +0200 To: suse-linux-e@suse.com
Hi all,
I'm trying to write a script that would connect via FTP to a list of hosts
and download two files.
I've the script working for one host and I'm trying to make it work with an
array of IP.
You will find the script below. When it runs it gives me a "syntax error:
unexpected end of file" message for the last line (exit 0)
If I comment all the FTP' stuff, it works (if we can say :-( and in the
while loop I can echo all the variables (like element_count ....) but
uncommenting the ftp lines breaks it.
I've been googling without any success. I'm wondering whether it's possible
to establish an FTP session in a loop or whether it should another way
(which one) to do it?
Thanks
Gaël
#!/bin/bash
# here is my script
declare -a IP
# All subsequent commands in this script will treat
# the variable "IP" as an array.
# List of all the APC's IP
IP[0]="xxx.xxx.xxx.xxx"
# parameters common to all the APC UPS
Directory="/"
User="xxx"
Password="xxx"
element_count=${#IP[@]}
# Special syntax to extract number of elements in array.
index=0
set -x
# turn tracing on
while [ "$index" -lt "$element_count" ]
do
ftp -n ${IP[$index]} <<End-Of-Session
# -n option disables auto-logon
user "$User" "$Password"
cd $Directory
get event.txt
get data.txt
bye
End-Of-Session
let "index = $index + 1"
done
set +x
#turn tracing off
exit 0
- Previous message: Ronald Wiplinger: "[SLE] mysql client server, sock miss-match"
- Next in thread: Ulf Rasch: "Re: [SLE] Bash script: problem in using ftp -n $server <<End-Of-Session in a while loop"
- Reply: Ulf Rasch: "Re: [SLE] Bash script: problem in using ftp -n $server <<End-Of-Session in a while loop"
- Reply: Scott Leighton: "Re: [SLE] Bash script: problem in using ftp -n $server <<End-Of-Session in a while loop"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- Re: FTP delete problem
... the problem was a lock to a file that the ftp get worked, ... Bernard Cheah
ha scritto: ... generate by schedule task. ... If i manually execute the script,
the output wrote, but by schedule ... (microsoft.public.inetserver.iis.ftp) - Re: FTP delete problem
... Yes, the script looking the previous day log file, but when it's still ... Bernard
Cheah ha scritto: ... the problem was a lock to a file that the ftp get worked, ...
generate by schedule task. ... (microsoft.public.inetserver.iis.ftp) - Re: [SLE] Bash script: problem in using ftp -n $server <<End-Of-Session in a while loop
... > I'm trying to write a script that would connect via FTP to a list of hosts
... > uncommenting the ftp lines breaks it. ... Have a look at the program wget
to download the files. ... (SuSE) - SUMMARY: AUTOMATED FTP WITH TWO LOGINS
... The script is now working, Michael DeSimone made the below suggestion: ... AUTOMATED
FTP WITH TWO LOGINS ... can't find list of remote files, ... (SunManagers) - Re: Scripted FTP transfer
... Rather then specify the username and password in your script, ... going to run
the ftp script, ... If you are running this from root, the .netrc will be created
in / ... I'm trying to write a FTP command file on the fly to ... (comp.unix.sco.misc)