FTP Script

Hi All,

I am trying to write a script that will issue a ftp command and then read the prompt and write the required values.


ftp host1
I need to read the prompt for user name and then echo the user name to the prompt

I need to read the prompt for password and then echo the
password to the prompt

cd mydir
put myfile myfile2


Any ideas, I have tried alot of different things but the bottom line is I get invalid command errors.


For the FTP userid and password, you can use the .netrc file. Try doing a man on netrc (man netrc) and check it out. As for the script, search the forum for a thread on how to do this using TELNET. There is a lot of info in the board on doing this with TELNET. If you combine the same ideas for TELNET with the .netrc file, you can rock-n-roll :slight_smile:

I leave it up-to-you to search for the thread on TELNET and scripting, if that is OK with you :wink:


I got the .netrc file setup and I piped it to the ftp command! Works great. Heres the script:

(echo cd mydir
echo put myfile.txt hostfile) ftp hostname

Pretty simple. The one question is should I but in a echo quit?

Thanks Again