LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 12-31-2007, 03:52 AM   #1
dreammold
LQ Newbie
 
Registered: Dec 2007
Posts: 1

Rep: Reputation: 0
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?
 
Old 12-31-2007, 04:44 AM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
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.
 
Old 12-31-2007, 07:07 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
You could call the ftp command like:

Call it like
ftp user:password@host << EOF
get games.log
del games.log
bye
EOF
 
Old 12-31-2007, 07:10 AM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by MS3FGX View Post
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
 
Old 12-31-2007, 08:36 AM   #5
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

Rep: Reputation: 57
Code:
man wget
/ftp ENTER
n
n
n
...

I d bet it can download from the ftp

Code:
man tail
was swiftly

Last edited by frenchn00b; 12-31-2007 at 08:39 AM.
 
Old 12-31-2007, 09:43 AM   #6
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
Quote:
You could call the ftp command like:

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:

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.
 
Old 12-31-2007, 12:39 PM   #7
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,546

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
In plesk , I wish to have a backup cron job, ftp back up file to another ftp server? muskiediver Linux - General 6 07-16-2009 04:13 AM
delete mails thru cron job massoo Linux - General 0 01-12-2005 03:19 AM
Cron - Delete Files nigeledge Linux - Software 1 10-14-2004 11:36 PM
cron aged delete jmanjohn61 Linux - General 1 09-22-2004 06:30 PM
howto delete files via ftp from cron job ? cccc Linux - Networking 2 01-31-2004 07:49 PM


All times are GMT -5. The time now is 04:06 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration