Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-14-2005, 02:05 AM
|
#1
|
|
LQ Newbie
Registered: Mar 2005
Location: India
Posts: 7
Rep:
|
cron job for expect script
I have written a script using Expect tool and obviously Tcl.
Now, this script gives an output as desired when run on the shell prompt.
However, when a cron is set to execute this script every 15 mins, it send mail saying that the program that im trying to spawn using the script is not found and that the process is invoked frm within.
If any body can help me with this issue.......it would b great.
I jus wanna know what are the checkpoints that are to b considered for the script to run in cron job.
And where am i missing out on them. Also, when do we get such an eoor message in the mail when executed in the cron.
Thanks in advance.
|
|
|
|
03-14-2005, 02:18 AM
|
#2
|
|
Member
Registered: Nov 2004
Location: BIOS
Distribution: RHEL3.0, FreeBSD 5.x, Debian 3.x, Soaris x86 v10
Posts: 379
Rep:
|
Make sure at top of script you have
Code:
#!/usr/bin/expect -f
Script has executable permission
Code:
chmod +x /path/to/my.exp
Hope this helps
|
|
|
|
03-17-2005, 03:36 AM
|
#3
|
|
LQ Newbie
Registered: Mar 2005
Location: India
Posts: 7
Original Poster
Rep:
|
Thanks a lot for ur help.
|
|
|
|
03-17-2005, 03:51 AM
|
#4
|
|
LQ Newbie
Registered: Mar 2005
Location: India
Posts: 7
Original Poster
Rep:
|
Hi,
Thanks again for ur help.
I had included the code #! /usr/bin/expect -f at the start of my script.
Also, the script is executable as it runs on the shell properly giving desired output.
What else do i need to check in that case.
Ruchita
|
|
|
|
03-17-2005, 04:21 AM
|
#5
|
|
Member
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273
Rep:
|
What is the exact error message? Please copy it from your mail and post it here.
I suspect your PATH is wrong.
Groetjes,
Kees-Jan
|
|
|
|
03-17-2005, 08:08 AM
|
#6
|
|
LQ Newbie
Registered: Mar 2005
Location: India
Posts: 7
Original Poster
Rep:
|
tHE ERROR MESSAGE THAT I GET WHEN MY SCRIPT IS SET ON CRON IS :
bash: couldnt execute "THE spawned APPLICATION"no such file or directory.
while executing
" spawn application mo_ip"
(procedure "do_attempt" line 5)
invoked from within
" do_attempt $app_name $mo_ip"
(file ./sysusage line30 )
Here i cannot reveal the applicationinvoke and hence used APPLICATION instead.
Using the script im trying to invoke an applicationthat gives me some system details.
I give username and password to start the applicationand cmd which i want o/p.
Also note that once my application starts the prompt is APPLICATION Name >
and not the normal shell prompt $.
Thanks,
Ruchita
|
|
|
|
03-17-2005, 08:36 AM
|
#7
|
|
Member
Registered: Nov 2004
Location: India
Distribution: RedHat, PCQLinux, Fedora
Posts: 95
Rep:
|
hi,
This looks like the problem of the exe not present in the path.
In the expect script try,
spawn APPLICATION_WITH_FULL_PATH mo_ip
Then call from the crontab.
While executing from the command line, the application u r trying to execute would have been in the path. (probably it would been added from the .bashrc)
|
|
|
|
05-27-2005, 04:12 AM
|
#8
|
|
LQ Newbie
Registered: Mar 2005
Location: India
Posts: 7
Original Poster
Rep:
|
The Expect script is in the Home directory .
The script looks like this :
#! /usr/bin/expect -f
set d [timestamp -format %H%d%m]
log_file -a sysusage_$d.txt
set prompt "APPL> "
global argc
if { $argc !=0 } {
send_user "Invalid number of args"
send_user "Usage: $argv0"
exit -1
}
set server_ip x.x.x.x
set app_name y
set timeout 5
proc do_attempt { app_name server_ip } {
global prompt
set timeout 5
log_user 0
spawn appl -i $server_ip
expect "login: " { send "login\r" }
expect "password: " { send "password\r" }
expect "WMS-TL1> " { send "command;\r" }
expect {
-re "More..." {
send "\r";
exp_continue;
}
expect "APPL> " { send "exit\r" }
}
}
do_attempt $app_name $server_ip;
exit
|
|
|
|
05-27-2005, 04:15 AM
|
#9
|
|
LQ Newbie
Registered: Mar 2005
Location: India
Posts: 7
Original Poster
Rep:
|
the above mentioned script runs well on the promp but not when a cron job is set.
The error message it gives is given above in the mail chain.
Kindly suggest as to what else can i add to run it as a cron job.
|
|
|
|
05-27-2005, 04:34 AM
|
#10
|
|
Member
Registered: Sep 2004
Distribution: Debian, Ubuntu, BeatrIX, OpenWRT
Posts: 273
Rep:
|
Like mentioned above, the application to be spawned cannot be found when running from cron.
Either use the full path to the application in the script, or make sure the path is set correctly.
Groetjes,
Kees-jan
|
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:54 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|