Reputation: 5127
I am running a unix command say ftp to a remote machine through a shell script.I have to pass the userid and password through the script accordingly.How can i do that?
Upvotes: 2
Views: 980
Reputation: 21357
Do you mean you want to get the result that the command (say, ftp) wrote to the terminal as a value inside the script?
Use backticks. For example:
x=`ftp ...`
will run the ftp
command, and take the text of its stdout and store it in the variable x
.
Upvotes: 0
Reputation: 2871
Best way to supply username/passwords from scripts would be to use 'expect' scripting.
Here is a small example : http://www.linuxquestions.org/questions/linux-software-2/auto-ssh-login-expect-script-624047/ . It shows using expect to provide password for ssh, ftp should be very similar.
Upvotes: 1
Reputation: 67211
Redirect the ftp command inside your shell script
ftp ..... > ftp.log
Upvotes: 0