Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I can write a script that will log me into an ftp server, navigate locally and remotely, put a file on it and then leave. But trying to build it into a loop so I could transfer several files is proving to be an arsehole. I have been fannying about with it for ages. I think the problem is that anything in my script after sending ftp the quit, bye or exit command doesn't get executed so my loop never reaches it's end.
How do I get my script to carry on going after exiting ftp?
#!/bin/sh
HOST='ftp.blah.blah.blah'
USER='user'
PASSWD='password'
LOCALDIR='/home/user1/ftptestdir/'
REMOTEDIR='/home/user2/ftptestdir/'
cd $LOCALDIR
for i in `ls *.jpg`
do
ftp -n $HOST <<ADAM
quote USER $USER
quote PASS $PASSWD
cd $REMOTEDIR
lcd $LOCALDIR
put $i $i
bye
echo "All done"
done
It never gets as far as echo "All done". Someone has let me know another way of getting the result I am after but I would like to understand why this one doesn't work.
ADAM is the end marker for the ftp part of the script, so you must put that on its own line after bye. This way you'll get "All done" printed once for each file, not sure if that's what you intended. The other way is to use mput *.jpg. In that case ftp must be started with the -i flag to turn off the confirmation prompt.
Thanks a lot, that sorted it out. But now I have another problem. This script cannot handle file names with spaces. I have tried everything I can think of, I've tried adding -Q to the ls bit and I've tried putting changing put $1 $1 to put "$1" "$1" but no joy. Can you tell me what I'm doing wrong?
Hi:
I have this strange problem. I want to just fetch newer files from the remote ftp server. I have automated the ftp login script. It logs in beautifully but then to check whether the file is new and just get the newer files is still a challenge. I want to know like is there anyway i can run a shell script on the remote server using ftp. By the way remote ftp server is owned by us and is a Linux SuSE 9.0. Any help in this direction will be appreciated.
thanks a lot
Chet
U T Dallas
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.