LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Trying to schedule ftp login using cron (https://www.linuxquestions.org/questions/linux-general-1/trying-to-schedule-ftp-login-using-cron-331882/)

compuser 06-09-2005 10:09 AM

Trying to schedule ftp login using cron
 
Hi everyone,
I have a fairly limited knowledge of linux and am having an unusual problem. I am trying to use cron to schedule automatic updates of my dat files by logging into McAfee's ftp server and downloading them. I am trying to do this by using a script that I got from the McAfee site. The script contains two parts. One is the .netrc file which contains login details and which I place in the root home directory. The other is a script called update.sh which contains the commands for logging into the ftp server, checking for new dats and updating them if available.
What is unusual about my problem is that, if I am logged in as root, I can manually run the update.sh script and it works fine. However, when I schedule the script to run by placing it in /etc/cron.daily it does not work. The following are parts of the messages which are mailed to root on a daily basis:

login failed.
Name (ftp.nai.com:root): /etc/cron.daily/update.sh: line 31: [: *.ta: integer expression expected
tar: dat-*tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

I think the important part of the message is the "login failed" bit. The rest is simply due to the fact that the script cannot get to the dat files (due to the failed login obviously).
Because the script works when I run it manually I think it might have something to do with the fact that the .netrc file is inacessable when run using cron. I find this odd though as cron runs as root.

Does anybody have any ideas?
Thanks in advance

keefaz 06-09-2005 11:03 AM

Could you post your crontab line ?

compuser 06-10-2005 04:22 AM

Hi Keefaz,
I don't have any crontab line as such. I just put the script into the appropriate cron directory (in this case /etc/cron.daily). To do this I log in as a normal user and su to root. Is this ok or do I need to log in directly as root?
Here is a copy of the system crontab file (located in /etc/crontab). I don't suppose there's anything interesting in it though as its pretty much your standard crontab file!

I'd appreciate any help you can give me.

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts

# Run Every 5 Minutes
*/5 * * * * root run-parts /etc/cron.5min

# Run Backup each weekday @ 10PM
0 22 * * 1-5 root run-parts /etc/cron.backup

0 */2 * * * root run-parts /etc/cron.2hours

01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly


All times are GMT -5. The time now is 09:20 AM.