LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 06-08-2015, 07:56 AM   #1
Ferazev
LQ Newbie
 
Registered: Jun 2015
Posts: 2

Rep: Reputation: Disabled
FTP Script does not work via cron


Hi,
I have a script wich includes FTP commands.
If I execute it interactively it works as expected.
When I execute via cron it doesn't copy files existing in remote server

This is the script FTP portion (I changed only the server and user names)

ftp -in << FIMFLG
open ftp_server
user ftpuser ftppwd
verbose
cd /OUT
bin
get teste.txt
bye
FIMFLG

This is the resulting output
Verbose mode on.
250 CWD successful. "/OUT" is current directory.
200 Type set to I
local: teste.txt remote: teste.txt
500 The server returned invalid response for PASV command.
Passive mode refused.
221 Goodbye

File teste.txt is not copied
What should I do ?
Thanks


I fixed this with a different approach.
Instead of starting it every five minutes via cron, I include a cycle in the script (finished by the existence of a control file) and submit it with nohup

Last edited by Ferazev; 06-19-2015 at 07:40 AM. Reason: Solved
 
Old 06-08-2015, 08:27 AM   #2
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 2,402

Rep: Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970Reputation: 970
ftp not working cron

1. Normally the first thing I recommend is to check the difference in PATH between interactive and cron, but that does not appear to be at issue here. Still, it will not hurt to check that. Settings PATH in your script is an easy way to avoid issues.

2. Have you considered sftp? Not only more secure, it is less dependent upon the remote software, as it is generally OpenSSH end to end.

:It looks like there are several things you could set and try.

3. Your script does not appear to explicitly set the current folder locally before running ftp. It really should.

4. PASV can be set, and unset. It does not appear to me that the PASV default should be different under cron or in an interactive shell, but that is one thing to consider.

5. Have you tried/considered lftp? Not only can it be used for many protocols, it is VERY scriptable!
 
Old 06-19-2015, 07:34 AM   #3
Ferazev
LQ Newbie
 
Registered: Jun 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
1. Normally the first thing I recommend is to check the difference in PATH between interactive and cron, but that does not appear to be at issue here. Still, it will not hurt to check that. Settings PATH in your script is an easy way to avoid issues.

2. Have you considered sftp? Not only more secure, it is less dependent upon the remote software, as it is generally OpenSSH end to end.

:It looks like there are several things you could set and try.

3. Your script does not appear to explicitly set the current folder locally before running ftp. It really should.

4. PASV can be set, and unset. It does not appear to me that the PASV default should be different under cron or in an interactive shell, but that is one thing to consider.

5. Have you tried/considered lftp? Not only can it be used for many protocols, it is VERY scriptable!

Thanks for the lftp hint. I will try it for other situations.
 
  


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
Cron doesn't work for Perl script Ale87zorg Linux - Server 9 10-10-2012 04:46 PM
Cron Job - FTP Upload File script stuartornum Linux - General 3 09-23-2012 01:34 PM
ftp script with cron problem mnauta Linux - General 4 09-15-2006 10:59 AM
cron+script+FTP tommytomato Linux - General 6 01-14-2006 12:53 AM
FTP Script will not run from Cron grhansen Programming 12 01-13-2006 05:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:54 PM.

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