LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-17-2007, 04:59 AM   #1
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Rep: Reputation: 52
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.

Last edited by rblampain; 05-17-2007 at 05:01 AM.
 
Old 05-17-2007, 02:26 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

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

Code:
man ftp
Hope this helps.
 
Old 05-18-2007, 02:43 AM   #3
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
Thank you for the tip, I will try that.
 
Old 05-18-2007, 02:46 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You could also try:
Code:
...
ftp user:password@myisp << EOF
cd ..
cd f8e6
binary
lcd /var
lcd www
put bunobla
bye
EOF
 
Old 05-19-2007, 12:40 PM   #5
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
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.
 
Old 05-20-2007, 12:30 AM   #6
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating FTP upload via a shell script? Spitty Programming 5 01-16-2006 10:28 PM
Connection, login and upload files to ftp server via shell script Paulo Góes Linux - Networking 2 02-21-2004 01:01 PM
my adding user script seems weird and buggy nzx Programming 1 10-21-2003 07:29 AM
Cant upload to another FTP brandog Linux - Software 1 05-03-2003 02:47 PM
ftp upload hotrodowner Linux - Networking 20 10-11-2002 04:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration