Crond help: Script Runs from command line, but not from cron

Crond help: Script Runs from command line, but not from cron

Post by erich trowbridg » Thu, 26 Sep 2002 00:34:44



I have written a little expect/tcl script that uses ssh to connect to the
routers around our ISP, writes the config and saving it to a file on the
server.

The script works great from the command line, saving all configs to the
appropriate file.

When I run the task from cron, however, the files are cut of about half way
through and the script doesn't finish. Some of these router configs are
long: it looks as if cron doesn't wait around long enough for the script to
finish. (Is my script a child of cron? Is there someway to make cron jobs
take their time in terminating?)

Anyway, if anybody has any suggestions of things to try, it would be greatly
appreciated.

thanks in advance,
erich
I am running x86 RH7.3 Kernal 2.4.18-3

<in /etc/crontab>
*/30 * * * * root /home/ewtrowbr/backup.sh router1 >>
/home/ewtrowbr/router1`date -I`

<backup.sh>
#!/usr/bin/expect -b
# Backup Radius account
set USER xxxx
# Acct Passwd
set PASS yyyy
#router enable passwords
set ENPASS1 zzzz
set ENPASS2 qqqq
set HOST [lindex $argv 0]
set send_slow {1 .1}
spawn -noecho ssh -l $USER $HOST
expect timeout {send_user "Can't connect\n"; exit}\
        -re "password:" {sleep 3; send -s $PASS\r}
expect -re ".*" {sleep 2; send -s "enable\r"; sleep 2}
expect -re "Password:" { if {$HOST == "christine"} {send -s $ENPASS2\r} else
{send -s $ENPASS1\r}}
expect -re "#" {send -s "term len 0\r show run\r"; sleep 30; send "exit\r"}
interact -nobuffer -re ".*" { send "exit\r"}
exit

 
 
 

Crond help: Script Runs from command line, but not from cron

Post by ynotsso » Thu, 26 Sep 2002 01:19:58



> I have written a little expect/tcl script that uses ssh to connect to the
> routers around our ISP, writes the config and saving it to a file on the
> server.

> The script works great from the command line, saving all configs to the
> appropriate file.

> When I run the task from cron, however, the files are cut of about half way
> through and the script doesn't finish. Some of these router configs are
> long: it looks as if cron doesn't wait around long enough for the script to
> finish. (Is my script a child of cron? Is there someway to make cron jobs
> take their time in terminating?)

> Anyway, if anybody has any suggestions of things to try, it would be greatly
> appreciated.

> thanks in advance,
> erich
> I am running x86 RH7.3 Kernal 2.4.18-3

> <in /etc/crontab>
> */30 * * * * root /home/ewtrowbr/backup.sh router1 >> /home/ewtrowbr/router1`date -I`

[...]

What is the command "root" doing? If that is an actual command (and not an error on your part)
then have the absolute pathname instead of a relative one.

    tony

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 
 
 

1. Script Runs Ok At Command Line, Not Cron

Hi. We're running AT&T Interactive Unix version 4.1.
We have a script that runs fine under root at the command prompt #.
However, when we include this script in our cron (root file) such as
30 15 * * * /path/to/script  this is the error that shows up in the
mail:

Cannot read message file:  operating system error 2

What is so different about running it on the command line vs a cron?
What am I obviously missing here?  Thanks.  

2. REQ: Please Help Newbie

3. How to tell if script is run from cron or command line?

4. Linux/Windows DMA incompatibility

5. Command Line Script runs fine get bad substititon from cron

6. Automount vs. LDAP

7. Cron Problems - Script runs from shell but not cron

8. qmail Question

9. Postgres95 search script: runs from command line but not when executed by server!

10. Script running from command line or called by other script: how tell?

11. help:why program can be run inside gdb but can not in command line

12. HELP -- execute some scripts from the command line as a command??????

13. cron - not executing all commands in a shell script