Operating System - Linux
1753454 Members
6174 Online
108794 Solutions
New Discussion юеВ

Re: Facing problem in Expect scripting. <Suggest any alternative to Sleep command>

 
Suresh Hegde
New Member

Facing problem in Expect scripting. <Suggest any alternative to Sleep command>

I am writing an expect script (executing on linux) to automate the BACKUP/RESTORE system disk on the OpenVMS.

------------------------------------------
i.e below piece of code works properly if the sleep time provided is sufficient to complete BACKUP/RESTORE.

send "Backup ...\r"
sleep sleep_time
expect -re $R_prompt

------------------------------------------

Time to complete the execution of command varies based on the size of data. So there may be head ache of calculatin exact time required for the execution. (if sleep time provided is less than the time required for execution, then the expect fails..)

So is there any alternative way for this. I even tried with while{} loop which fails to break after execution (as below),

------------------------------------
send "BACKUP/IMAGE ...\r"
while {1} {
expect {
-re $R_prompt {
break;
}
}

}
------------------------------------
2 REPLIES 2
Steven Schweda
Honored Contributor

Re: Facing problem in Expect scripting. <Suggest any alternative to Sleep command>

> [...] automate the BACKUP/RESTORE system
> disk on the OpenVMS.

What is there to automate? One BACKUP
command? Why sleep for any particular amount
of time? Why not simply wait for the command
to finish (and the next prompt to appear)?

Is there some actual problem which you are
trying to solve?

(Or will your script load a second tape into
the tape drive when the first one is full?)

You're connected to the VMS system how,
exactly? Serial line, Telnet/rsh/ssh, what?
Suresh Hegde
New Member

Re: Facing problem in Expect scripting. <Suggest any alternative to Sleep command>

My problem is not at the VMS end, but at the linux Expect scripting.

"(Other than using sleep method)How to wait for the sent command for long time (may be more than an hour)? "

I am connecting to VMS from linux box through telnet (to be specific, using expect script on linux).

Thanks
Suresh