Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
Hey everyone I need a little help here. I want to setup a cron that will do 3 things.
1) It will connect via ftp to a server and download a file called games.log
2) Then delete the source games.log from the ftp site after the download finished.
3) Then run this command line shell
php vsp.php -l wet "/public_html/wet/games.log"
I ask because FTP is rather difficult to script as there is no way to control it via command line switches, it needs to be controlled interactively as if you were sitting there typing commands into it.
In contrast, if you could use some mountable network filesystem (NFS, SSH, etc) then you can mount the remote machine and operate on the files as if they were local.
Not to say doing it over FTP isn't possible, it will just be harder. I have certainly never been able to script the functionality I have wanted when using an interactive FTP client, at least.
I ask because FTP is rather difficult to script as there is no way to control it via command line switches, it needs to be controlled interactively as if you were sitting there typing commands into it.
Not really
Code:
ftp -n ftp.server.com << EOF
user anonymous anonymous@gmail.com
get games.log
delete games.log
bye
EOF
Call it like
ftp userassword@host << EOF
get games.log
del games.log
bye
EOF
The problem with this, at least in my experience, is that it works fine as long as everything goes according to plan. It is difficult to accurately catch and handle errors in this scenario since the script can't interact with the FTP client itself, and is just sending canned messages to it.
For example, if we could call an ftp client with commands like:
We could easily trap errors by checking the return value it gives back for each step; but when you just throw commands at the client, there is no way to tell were an error occurred so that it can be handled gracefully.
In man wget, I got this. This may maybe interest you.
Code:
wget -c ftp://sunsite.doc.ic.ac.uk/ls-lR.Z
Code:
Specify the username user and password password for both FTP and
HTTP file retrieval. These parameters can be overridden using the
--ftp-user and --ftp-password options for FTP connections and the
--http-user and --http-password options for HTTP connections.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.