Linux - Newbie This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
12-31-2007, 02:52 AM
|
#1
|
LQ Newbie
Registered: Dec 2007
Posts: 1
Rep:
|
Cron FTP get and delete
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"
Can someone please help me out with this?
|
|
|
12-31-2007, 03:44 AM
|
#2
|
LQ Guru
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852
|
Does it have to use FTP?
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.
|
|
|
12-31-2007, 06:07 AM
|
#3
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
You could call the ftp command like:
Call it like
ftp user:password@host << EOF
get games.log
del games.log
bye
EOF
|
|
|
12-31-2007, 06:10 AM
|
#4
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
Quote:
Originally Posted by MS3FGX
Does it have to use FTP?
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
|
|
|
12-31-2007, 07:36 AM
|
#5
|
Senior Member
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561
Rep:
|
/ftp ENTER
n
n
n
...
I d bet it can download from the ftp
was swiftly
Last edited by frenchn00b; 12-31-2007 at 07:39 AM.
|
|
|
12-31-2007, 08:43 AM
|
#6
|
LQ Guru
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852
|
Quote:
You could call the ftp command like:
Call it like
ftp user assword@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:
Code:
ftp user:password@host -get games.log
ftp user:password@host -del games.log
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.
|
|
|
12-31-2007, 11:39 AM
|
#7
|
Senior Member
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 08:24 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|