Time out in shell script for a stament/line

Folks,
In shell script, can I mention a timeout for a command execution, afterwhich I want to exit from that particular line and proceed furthur.

I have part of my script as below:
******************************
cd $EXPECT_HOME
expect custom_install.exp mv $QA_HOME/install_run/logs/task*.xml $QA_HOME/install_run/logs/console

.....and so on...

********************************

Problem I am cing is, its hanging at the end of Expect script execution..
I just wanna comeout of that after say 2 mins and proceed.
(Expect time out in expect script doesnt work for me somehow).
So, from shell script, can I handle it somehow?

Thanks for ur time.

--Venkat.

Place an 'exit' at the point in the script where you need to exit.

If you need, place an exit code (eg: 'exit x' - where x = 0-?? ).
And then subsequent scripts can execute based on the exit code issued.

Hope I got your query right & it helps some. :wink:

Cheers,
Cameron

Thanks Cameron.
But the problem is my script is not coming out of that expect call.
exit inside expect is not working for me.

I just want to comeout of expect call after 2 mins and proceed furthur in my shell script..

Anymore thoughts?

Thx in advance.

You would need to

spawn a child process which captures it's pid
spawns another child process which does sleep followed by kill of that pid
set up a trap handler
spawn another child process to exec the command capturing the pid of that process
wait for the exec child to finish
clear that pid variable
in the trap handler, if the pid variable is still set then kill that pid
if the killer child has not finished, kill it

alarming?

Show us your expect script. Looks like you may not coded it to
include timeouts or EOF situations Expect can hang on timeout
if waiting for a particular pattern but receives EOF instead.

Thanks guys.

Murphy, yes..better I should code my expect script correct.
Below is the peace of code @ the end of my .exp script.

******************************************

expect "*Next\]> "
sleep 3
expect -timeout 30 "*Exit\]> "
sleep 5
send -- "Exit\r"
send -- "\r"
sleep 3
send -- "\r"
sleep 3
send -- "exit\r"
sleep 5
Exit
##send -- "Next\r"
sleep 3
send -- "exit\r"
sleep 3
Exit 0
send -- "Exit\r"
sleep 3
exit 0
expect "*Exit\r]> "
sleep 5
exit 0
send -- "Exit\r"
sleep 3
exit

*********************************

I simply placed so many exits, hoping atleast 1 will click.
(I m a newbie in Expect scripting :))

and my script simply hangs on..after successful execution.

Thanks for your time.
--Venkat.