Operating System - HP-UX
1819791 Members
3300 Online
109607 Solutions
New Discussion юеВ

Expect script not running in Crontab

 
Ashok_17
Occasional Contributor

Expect script not running in Crontab

I have a shell script which inturn runs an expect script which just telnets to another machine..
Its running fine when i run the shell script manually
but not when in crontab
4 REPLIES 4
Patrick Wallek
Honored Contributor

Re: Expect script not running in Crontab

You probably do not have your environment set up correctly for the script to run via cron.

You must remember that when something runs from cron, the environment is VERY VERY sparse. There is little, or no, PATH environment which is the usual cause of problems.

Set ANY and ALL environment variables you need within the script itself. You also should fully qualify ALL programs and commands that you run within the scripts so that you know exactly which ones are running and you have the exact path to them.
Steven E. Protter
Exalted Contributor

Re: Expect script not running in Crontab

from command line:

env > /tmp/regular.env.txt

from the script running in cron

env > /tmp/cron.env.txt

diff /tmp/cron.env.txt /tmp/regular.env.txt

You will notice a massive difference.

Any variable could cook this process.

Look first at PATH

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Sridhar Bhaskarla
Honored Contributor

Re: Expect script not running in Crontab

Hi Ashok,

Most probably the environment as mentioned before. You can get more information from the following.

1. Check the mailbox of the user you are running the script as on the box. Login as that user and run 'elm' and look at the mail. Any errors will go to the local mail if not auto forwarded.
2. Redirect the errors to some file and look at the file after the job is run.

For ex., make your crontab as

12 * * * * /your_dir/your_scr >> /tmp/your_scr.out 2>&1

You will get clues from the above.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Ashok_17
Occasional Contributor

Re: Expect script not running in Crontab

Thank u all for ur timely suggestions

I debugged the error..

I used sleep.. after the sleep-expect and
pwd-expect. and at the end i used interact..

I now changed it to ..no sleeps..
and expect eof at end of expect script..

Thanku all once again.
I keep informing u about my problems.. in future