Here's how to write a simple ftp script on unix or windows without having to worry about those passwords.
Using EOF
Probably the most common is to use the EOF (end of file) method. Its important to know that there cannot be any spaces in front of the last 'EOF' line.
ftp -nv hostname << EOF
user USERNAME PASSWORD
cd directory
prompt
passive
asc
mput filename.*
bye
EOF
Using .netrc
The other method of saving passwords for multiple scripts is to use a .netrc file which can be created in the user's home directory
$ cd $HOME
$ vi .netrc
add the following line into the file
machine
$ chmod 500 .netrc
You should be able to ftp without prompts. to test, just type
$ ftp
you should be logged in. the downside is that this forces you to log in as that specific user. However lets face it, if you're still using ftp to move stuff around, this shouldn't bother you one bit.
Personally, I would recommend that sftp or scp be used instead. pub key management is so much more convienient.
No comments:
Post a comment