|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
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?. |
|
#3
|
|||
|
|||
|
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.
|
|
#4
|
||||
|
||||
|
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. |
|
#5
|
|||
|
|||
|
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? |
|
#6
|
||||
|
||||
|
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?
|
|
#7
|
|||
|
|||
|
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. |
|
#8
|
||||
|
||||
|
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 Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month |
|
#9
|
||||
|
||||
|
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. |
|
#10
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > BSD Help > Help with cronjob/shell script |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|