Hi, I got your reference from a website while looking for a solution of a problem. here is the problem: I have a expect scrips which does rlogin and then runs a script there. on sun solaris box "a12345", i have a scripts
It will rlogin to box "b12345" and will run script runScript under /home/testuser directory. When I run this script on command prompt, it runs fine. But if I try to run this script it is is not working. I believe since crontab sets the shell to csh first, that why am not able to run thid script.
Can you give me some solution. Pls help! thanks Ritesh
Hi Ritesh You could try telling cron to run expect with your file as the parameter. So something like: <code> * 1 * * * /usr/bin/expect -f <myExcpectScript.exp></code> But even with that, you will still have problems with the last line of your script, where you issue the command "interact". There is no user to interact with this script when running from a cron job. Regards, Andrew [ July 27, 2003: Message edited by: Andrew Monkhouse ]
I tried using /usr/bin/expect -f <filename> in crontab.. but its not working.. its gets stuck when expecting password... though its working from command prompt as you said Andrew, its because of "interact"... any solution for this problem ??
author and jackaroo
Hi Ritesh When you run a job using cron, you have a very limited environment, and there are many environmental variables that are either not set, or set differently, to an interactive prompt. One of the environmental variables that is missing is the TERM variable, detaining what sort of terminal you are running from. This is only to be expected - if you are running from a cron job, you do not have a physical terminal attached (there is no keyboard or screen for the cron job). This is probably what is causing you problems. From my manual for rlogin: Try getting a command prompt, and type:<code><pre> unset TERM rlogin b12345</pre></code> Does this look different to what you expect? You are probably getting some notification that TERM is not set.
You may be asked what the TERM should be. In which case, just modify your script to answer that question
Or the rlogin may be exiting since it doesnt have the TERM set. In which case you will have to set the TERM variable in your crontab (<code>man 5 crontab</code>) or you will have to set the TERM variable in the expect script, or you will have to wrap the expect script in a shell script that sets the TERM variable.
As for the "interact" statement - why do you need it? It is not needed in the script you provided - try removing it and running the script from a shell prompt again - you should not see any difference. If you don't need it, remove it. Regards, Andrew
Joined: Jul 27, 2003
thanks Andrwe .. now am setting TERM in cron tab before calling the script but of no use.. i wrote a wrapper script which calls that script.. in wrapper script am setting TERM variable and exporting and then am calling that wrapper script from crontab... but still result is same....
author and jackaroo