LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   buggy ftp upload script (https://www.linuxquestions.org/questions/programming-9/buggy-ftp-upload-script-554580/)

rblampain 05-17-2007 04:59 AM

buggy ftp upload script
 
As I understand it, the following scripts should work automatically without human intervention when I enter "./tarnobla.sh". However I am prompted to enter the password and then the second script seems to stumble on the password and sees it as an "invalid command".

----- this is file tarnobla.sh:
#!/bin/bash
cd /var/www
tar cvpzf bunobla /home/nobla/*
ftp < /home/nobla/Desktop/ftpnobla

----- this is file ftpnobla:
open myisp
username
password
cd ..
cd f8e6
binary
lcd /var
lcd www
put bunobla
bye

The site is password protected and used only as a backup. After I enter the password, the script works properly.

Can anyone point me to the mistake?

Thank you for your help.

wjevans_7d1@yahoo.co 05-17-2007 02:26 PM

Use the -n switch on the ftp command line. Use the user command as described in:

Code:

man ftp
Hope this helps.

rblampain 05-18-2007 02:43 AM

Thank you for the tip, I will try that.

jschiwal 05-18-2007 02:46 AM

You could also try:
Code:

...
ftp user:password@myisp << EOF
cd ..
cd f8e6
binary
lcd /var
lcd www
put bunobla
bye
EOF


wjevans_7d1@yahoo.co 05-19-2007 12:40 PM

A potential problem with jschiwal's solution is that it places the password on the command line, making it readable by anyone on the same system through the ps command.

rblampain 05-20-2007 12:30 AM

It looks like my best option is to use the .netrc file as explained in the man page but it is good to know the other commands that can be used when automation is not required.

Thank you all.


All times are GMT -5. The time now is 05:49 AM.