- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- expect help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2003 06:43 AM
тАО09-19-2003 06:43 AM
expect help
I have an expect program in which I am trying to timeout after sometime, but my program is coming out before the timeout happens.
Here is the program :-
*********************
#! /usr/local/bin/expect
proc spawn_proc {args} {
global temp_id
puts "\t$args"
eval spawn $args
expect {
timeout { send_user "\nTimed out\n" }
}
return $spawn_id
}
# The program should wait for 100 secs and #then timeout
set timeout 100
spawn_proc ls
puts "program completed successfully "
# program end
****************************************
But with a small modification in the above programs it works as expected.
Modified program :-
*********************
#! /usr/local/bin/expect
proc spawn_proc {args} {
global temp_id
puts "\t$args"
eval spawn $args
return $spawn_id
}
# The program should wait for 100 secs and #then timeout
set timeout 100
spawn_proc ls
# expect statement is taken off in the #spawn_proc and kept here .
expect {
timeout { send_user "\nTimed out\n" }
}
puts "program completed successfully "
# program end
***********************************************
One more difference in the outputs of the above two programs is In the 1st case ( non-timedout case) it displays the output of "ls"
command on the screen and exits without
waiting for the timeout to happen . But in second case it doesn't display the output to the screen , but it waits till timeout occurs .
Can somebody explain me the reasons for these behaviours ???
TIA,
vara.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2003 07:28 AM
тАО09-19-2003 07:28 AM
Re: expect help
I am new to expect as well, but I do have a couple of working scripts so I might be able to help once I understand what you really want to do.
-Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-19-2003 07:29 AM
тАО09-19-2003 07:29 AM
Re: expect help
I am new to expect as well, but I do have a couple of working scripts so I might be able to help once I understand what you really want to do.
-Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-20-2003 05:05 PM
тАО09-20-2003 05:05 PM
Re: expect help
I want my program to wait for 100 secs after "ls" is executed . Why is this not
happening in the 1st case ??? As I have not
put any matching patterns in expect , I expected the program to wait for 100 secs
in spawn_proc function . I could able to achieve the expected behaviour in the second
case with similar login .
Just execute the above two scripts . You will
see the difference .
TIA,
vara.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-22-2003 04:09 AM
тАО09-22-2003 04:09 AM
Re: expect help
ex: assume root is running this
eval spawn $args
expect {
timeout { send_user "\nTimed out\n" }
"# "
}
sleep 100
This will expect to get the prompt back within timeout period then sleep for 100 seconds.
Does this help? or do I not understand your question?
-Dave
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2003 03:54 AM
тАО09-24-2003 03:54 AM
Re: expect help
I think I didn't specify my requirement clearly . Here I am putting my requirement
exactly .
For simplying the problem I have used "ls"
as an arg to spawn_proc. You have suggested sleep to make it wait for 100secs after the execution of "ls" . But In my actual test script I want to create and delete the files
under some dir ( Its a "while true" loop ).
Here I am pasting that portion of code.
set timeout 300
spawn_proc /opt/ids/test/agent/common/realroot -c "\
mkdir -p /tmp/mydirtowatch;
while true
do
touch /tmp/mydirtowatch/file1;
touch /tmp/mydirtowatch/file2;
touch /tmp/mydirtowatch/file3;
rm /tmp/mydirtowatch/file?;
done"
So , Its is not just waiting . The script should execute the above while loop for 100secs and timeout after that. So I can't
use sleep here.
Let me know If you have any other idea to do this through expect script.
Regds,
Vara
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2003 04:14 AM
тАО09-24-2003 04:14 AM
Re: expect help
mkdir -p /tmp/mydirtowatch;
SECONDS=0
while [ $SECONDS -lt 300 ]
do
touch /tmp/mydirtowatch/file1;
touch /tmp/mydirtowatch/file2;
touch /tmp/mydirtowatch/file3;
rm /tmp/mydirtowatch/file?;
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-29-2003 03:27 AM
тАО09-29-2003 03:27 AM
Re: expect help
"set timeout -a"