LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   FTP Script (Automating) (https://www.linuxquestions.org/questions/linux-general-1/ftp-script-automating-32899/)

noodle123 10-15-2002 04:33 PM

FTP Script (Automating)
 
I'm trying to automate an ftp script so that it ftp's to various servers (rs001, rs002, rs003....) and send a file... and no, RCP won't work in my case.

But here's my script so far.

STORES="001 002 003 004 005"

for store in ${STORES}
do
ftp rs${store} <<ENDFTP
send file1
bye
ENDFTP
done

Now for some reason the script won't work and keeps giving this same error msg. "syntax error: unexpected end of file"

can't someone help me with this?

Note: I didn't use ftp -n because i don't need to enter password/user since when i use "ftp rs001" the login is automated already. Any help much appreicated.

markus1982 10-16-2002 02:09 AM

An example script of an FTP GET ... all you need to do is to convert that to STORE (and adjust user-details of course):
Code:

#!/bin/sh

cd /backups/databases
ftp -n hostname <<EOF
user username password
binary
cd /databases
get databases_2002-10-15@00-00.tar.bz2
dele databases_2002-10-15@00-00.tar.bz2
EOF

cd /backups/webserver
ftp -n hostname <<EOF
user username password
binary
cd /htdocs
get webserver_htdocs-2002-10-15.tar.bz2
dele webserver_htdocs-2002-10-15.tar.bz2
EOF

Oh and like trickykid said please DO NOT DOUBLE-POST! It's just annoying doing so!

noodle123 10-16-2002 08:17 AM

sorry for the double post, but the first post i think i buggered up cuz i hit 'back' by mistake. But the script above needs to be in a loop. I can make it do a one time get/send but i need to use the ftp script within a loop. Everytime i put it in a for loop it gives me unexpected end of file error which i don't know where it's coming from.

edit: i have about 100 different ftp servers i need to ftp ONE file to, so having the server (store) ips within a file it'll be quicker to have the script loop back rather than having 100 independent ftp gets.


All times are GMT -5. The time now is 01:32 PM.