General discussion

Locked

Passing arguments in Unix Shell Script

By pcammuso ·
In a shell script, I want to be able to "ftp" to a machine and pass the username, password, put command, etc. but whenenver I run the script, it sits there waiting for me to enter the info. I predefined them in the script, but I don't know how to pass them to the ftp command to get them to execute.

Thanks

Paul

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Passing arguments in Unix Shell Script

by rkeckler2000 In reply to Passing arguments in Unix ...

Try this in your script

ftp computer << EOF
user username passwd
cd /to/a/directory
put files
bye
EOF

Collapse -

Passing arguments in Unix Shell Script

by pcammuso In reply to Passing arguments in Unix ...

Sorry, this didn't work! I ended up writing the ftp commands to a file as follows

ftp hostname < file.txt

file.txt contains all I needed

Thanks for the repsonse anyway

Collapse -

Passing arguments in Unix Shell Script

by ajohn In reply to Passing arguments in Unix ...

Paul,
Basically, you need username, password, and the put command. The username and password should be written to the users .netrc file. It should look like this:
default
login whateverusername
password whateverpassword
I think permissions haveto be set to r--------. (chmod 400)
Then, all that is left is the put command. Write out the put command to a file and cat the file piping throu the ftp command.
like this:
echo "put filename" > dummyfile
cat dummyfile | ftp
I think this shouldat least get you started.
John

Collapse -

Passing arguments in Unix Shell Script

by pcammuso In reply to Passing arguments in Unix ...

See comment on Answer 1 above

Back to Linux Forum
4 total posts (Page 1 of 1)  

Related Discussions

Related Forums