net/ftp works manually, fails via cron

D

Daniel Berger

Hi all,

Ruby 1.8.2
Solaris 10, Linux 2.6.8

I'm experiencing something odd with net/ftp. When I run the following snippet
manually it works fine. Running the same snippet under cron seems to fail.

I don't get any messages in the log file. No indication whatsoever that there
was a problem. It's just that...nothing happens. There is no file transfer as
far as I can see when run via cron.

Any ideas?

Regards,

Dan

# ftptest.rb
require "net/ftp"
include Net

host = "some_host"
log_file = "ftptest.log"

fh = File.open(log_file, "w+")

begin
ftp = FTP.new(host)
ftp.login("djberge", "xxxxx")
ftp.chdir("local")
ftp.gettextfile("text.temp")
rescue Exception => err
fh.puts("FTP ERROR: #{err}")
raise
else
fh.puts("Got file")
end

begin
ftp.puttextfile("upload_test.txt")
rescue Exception => err
fh.puts("FTP ERROR: #{err}")
raise
else
fh.puts("Put file")
end

ftp.close
fh.close
 
J

Jamey Cribbs

Daniel said:
Hi all,

Ruby 1.8.2
Solaris 10, Linux 2.6.8

I'm experiencing something odd with net/ftp. When I run the following
snippet manually it works fine. Running the same snippet under cron
seems to fail.

I don't get any messages in the log file. No indication whatsoever
that there was a problem. It's just that...nothing happens. There is
no file transfer as far as I can see when run via cron.

Any ideas?
Some questions:

Did you add it to the root user's crontab or your user account's crontab?

When you run it manually and it works, are you running it as root or as
yourself?

In the crontab, did you specify the absolute path to both the ruby
interpreter and to your script file?

Jamey

Confidentiality Notice: This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and/or privileged information. If you are not the intended recipient(s), you are hereby notified that any dissemination, unauthorized review, use, disclosure or distribution of this email and any materials contained in any attachments is prohibited. If you receive this message in error, or are not the intended recipient(s), please immediately notify the sender by email and destroy all copies of the original message, including attachments.
 
A

Ara.T.Howard

Hi all,

Ruby 1.8.2
Solaris 10, Linux 2.6.8

I'm experiencing something odd with net/ftp. When I run the following
snippet manually it works fine. Running the same snippet under cron seems to
fail.

I don't get any messages in the log file. No indication whatsoever that
there was a problem. It's just that...nothing happens. There is no file
transfer as far as I can see when run via cron.

Any ideas?

path to ruby is fubar under cron? what's the shebang line and cron line?


Regards,

Dan

# ftptest.rb
require "net/ftp"
include Net

host = "some_host"
log_file = "ftptest.log"

fh = File.open(log_file, "w+")

begin
ftp = FTP.new(host)
ftp.login("djberge", "xxxxx")
ftp.chdir("local")
ftp.gettextfile("text.temp")
rescue Exception => err
fh.puts("FTP ERROR: #{err}")
raise
else
fh.puts("Got file")
end

begin
ftp.puttextfile("upload_test.txt")
rescue Exception => err
fh.puts("FTP ERROR: #{err}")
raise
else
fh.puts("Put file")
end

ftp.close
fh.close

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 
D

Daniel Berger

Jamey said:
Some questions:

Did you add it to the root user's crontab or your user account's crontab?

When you run it manually and it works, are you running it as root or as
yourself?

In the crontab, did you specify the absolute path to both the ruby
interpreter and to your script file?

Nope, whoops, that was it. I think I goofed the crontab, too, which is why I
got no error message.

Sorry for the noise.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top