The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Operating Systems
> BSD Help
|
Help with cronjob/shell script
Discuss Help with cronjob/shell script in the BSD Help forum on Dev Shed. Help with cronjob/shell script BSD Help forum discussing all BSD based operating systems including FreeBSD, OpenBSD, NetBSD, and more. BSD refers to the distribution of UNIX originally developed by the University of California at Berkeley.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

May 29th, 2006, 05:19 PM
|
|
Contributing User
|
|
Join Date: Nov 2003
Posts: 42
Time spent in forums: 6 h 59 m 41 sec
Reputation Power: 10
|
|
|
Help with cronjob/shell script
I have a shell script that I am tring to call from root's crontab. For some reason it is not working. The error seems to be: "Unknown command." The shell script is located in /. Here is the crontab entry.
59 23 * * * cd /; ./ftp_smarter.c
I have also tried /bin/sh ../ftp_smarter.c
Here is the shell script:
Code:
#!/bin/sh
HOST='hostname'
USER='username'
PASSWD='password'
FILE='grab.txt'
cd /home/price
/usr/bin/pftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit
END_SCRIPT
exit 0
|

May 29th, 2006, 06:22 PM
|
 |
Not a clue what to put ...
|
|
Join Date: Jan 2006
Location: in front of this keyboard
|
|
|
If you are wanting to execute ftp_smarter.c which is in the root directory then just use /ftp_smarter.c as the command - and make sure it is executable.
__________________
According to Sod's Law, buttered toast lands butter side down, when dropped.
Per nature, cats always land on their feet.
So, what happens when you strap buttered toast to the back of a cat and throw it out a window?.
|

May 29th, 2006, 06:54 PM
|
|
Contributing User
|
|
Join Date: Nov 2003
Posts: 42
Time spent in forums: 6 h 59 m 41 sec
Reputation Power: 10
|
|
|
OK, I set that as the command but I am still getting the same error. Is there something wrong with my script? I have no problems running it from the cli.
|

May 29th, 2006, 07:14 PM
|
 |
Not a clue what to put ...
|
|
Join Date: Jan 2006
Location: in front of this keyboard
|
|
You have the same form of quotes around the follwing lines:
Code:
HOST='hostname'
USER='username'
PASSWD='password'
FILE='grab.txt'
What exactly are you trying to do with them? Did you mean to set some of the variables to the return value of a command? If it runs ok from command line then I would suggest that your PATH is not set up correctly in the script.
|

May 29th, 2006, 07:47 PM
|
|
Contributing User
|
|
Join Date: Nov 2003
Posts: 42
Time spent in forums: 6 h 59 m 41 sec
Reputation Power: 10
|
|
My script now looks like this:
Code:
#!/bin/sh
PATH=/usr/local/bin:/usr/bin:/bin
HOST='hostname'
USER='username'
PASSWD='password'
FILE='grab.txt'
cd /home/price
pftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit
END_SCRIPT
exit 0
but I am still getting the exact same error? Should I try adding it to /etc/crontab to see if it works from there?
|

May 30th, 2006, 11:54 AM
|
 |
Not a clue what to put ...
|
|
Join Date: Jan 2006
Location: in front of this keyboard
|
|
|
It should not make much difference where it is (roots crontab or /etc/crontab). Do we know exactly what is casuing the error? Is there anything in roots mail?
|

May 30th, 2006, 11:39 PM
|
|
Contributing User
|
|
Join Date: Nov 2003
Posts: 42
Time spent in forums: 6 h 59 m 41 sec
Reputation Power: 10
|
|
The error that I am posting here comes from root mail. I have also checked /var/log/messages .. and etc. but have found nothing that relates to my issue. I am sure that I am doing something wrong because from my experience user error is usually to blame
I just can't seem to figure out what I am doing wrong. I did try adding it to /etc/crontab just to see what happens and came up with nothing. Thanks very much for your help. If you come up with any more ideas please post them here.
|

May 31st, 2006, 02:57 AM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|
Try adding some echo statements to the script and see if they show up in the logs. That way you may be able to isolate where the problem is.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|

May 31st, 2006, 05:10 PM
|
 |
Not a clue what to put ...
|
|
Join Date: Jan 2006
Location: in front of this keyboard
|
|
|
The use of echo for debugging is a good idea.
cron is normally, in my experience, a little friendlier with script errors which makes me continue to think it might be the actual crontab entry with the issue.
|

June 14th, 2006, 12:07 PM
|
|
Registered User
|
|
Join Date: Jun 2004
Location: BC, Canada
Posts: 16
Time spent in forums: 1 h 30 m 19 sec
Reputation Power: 0
|
|
Did you ever get this working? If not try this it works great for me (FreeBSD 4.10 and 5.5):
Code:
#!/bin/sh
HOST="hostname"
USERNAME="username"
PASSWORD="password"
FILE="filename"
ftp -d -n -v $HOST <<!
quote user $USERNAME
quote pass $PASSWORD
passive on
prompt off
progress on
binary
put $FILE
ls
bye
!
This assumes you are using the supplied FreeBSD FTP server and you have the path set correctly in your crontab.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|