BSD Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsBSD Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 29th, 2006, 05:19 PM
smoked1 smoked1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 42 smoked1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
  #2  
Old May 29th, 2006, 06:22 PM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 879 Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 10 h 27 m 24 sec
Reputation Power: 332
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?
.

Reply With Quote
  #3  
Old May 29th, 2006, 06:54 PM
smoked1 smoked1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 42 smoked1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #4  
Old May 29th, 2006, 07:14 PM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 879 Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 10 h 27 m 24 sec
Reputation Power: 332
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.

Reply With Quote
  #5  
Old May 29th, 2006, 07:47 PM
smoked1 smoked1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 42 smoked1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #6  
Old May 30th, 2006, 11:54 AM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 879 Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 10 h 27 m 24 sec
Reputation Power: 332
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?

Reply With Quote
  #7  
Old May 30th, 2006, 11:39 PM
smoked1 smoked1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 42 smoked1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #8  
Old May 31st, 2006, 02:57 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,387 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 21 h 39 m 3 sec
Reputation Power: 4080
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

Reply With Quote
  #9  
Old May 31st, 2006, 05:10 PM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 879 Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level)Ehlanna User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 10 h 27 m 24 sec
Reputation Power: 332
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.

Reply With Quote
  #10  
Old June 14th, 2006, 12:07 PM
Maniac Maniac is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Location: BC, Canada
Posts: 16 Maniac User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsBSD Help > Help with cronjob/shell script

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap