LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Scripting FTP Help (https://www.linuxquestions.org/questions/linux-networking-3/scripting-ftp-help-427700/)

pshankland 03-23-2006 11:24 AM

Scripting FTP Help
 
I am trying to script FTP so I can take a .tar file that I created and ftp it through to a Windows FTP server.

I have the following line in the script I created to create the tar file:

Code:

FTP < /scripts/ftpscript
And then in ftpscript I have:

Code:

open xxx.xxx.xxx.xxx
<username>
<password>
put *.*
bye

Problem is that this all works but the script just sits there waiting for a password.

Any ideas?

Thanks.

jjohnston62 03-23-2006 01:55 PM

scripted ftp........

Include ftp commands within the script, and process them with ftp -n

for example:

HOST='site.domain.com'
USER='username'
PASSWD='secret'
ftp -n $HOST
quote USER $USER
quote PASS $PASSWD

include all that in a shell script, and then execute your put $FILE command.

don't try to run the script through FTP

pshankland 03-24-2006 02:46 AM

Thanks. Have now got the following just in my shell script:

Code:

FTP_HOST=172.xxx.xxx.xxx
FTP_USER=username
FTP_PASS=password

ftp -n $FTP_HOST
quote USER $FTP_USER
quote PASS $FTP_PASS
put $BACKUP_FILE
bye

But just get the script sitting at:

Code:

2200 <FTPSERVER> Microsoft FTP Service (Version 5.0).
ftp>

And I have to manually type quit to end the script without it finishing.

Pete.

nx5000 03-24-2006 05:06 AM

Code:

#!/bin/sh
ftp -n web.site.com << EOF
user foo foo_password
cd /some/dir
bin
mget some_file
bye
EOF

Should work. It does for me

pshankland 03-24-2006 06:07 AM

Cheers nx5000, that worked fine :)


All times are GMT -5. The time now is 01:23 AM.