For Programmers: Free Programming Magazines  


Home > Archive > Tcl > August 2007 > Expect problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Expect problem
Swaroop

2007-08-25, 8:10 am

Hi,
I have the peace of code like this. i am calling a proc from Script
A. in script A if i set send_flag to False, in the script B, the send
command should not work. I am calling the proc in script B with
send_flag set to false, but i want the expect block to be executed.
The problem is when i am not sending anything, the control is not
going to the expect block. If i want the expect block to be executed
can i send "send -i $lspawn_id "" ".?


SCRIPT A:

"EthIPv4NetworkEnable" {
if {[catch {set rc [run_command_set_setup_system_ipv4 $lspawn_id
$EthIPv4NetworkEnbl
$EthIPv4NetworkDisc $EthIPv4NetworkAddr
$EthIPv4NetworkMask $EthIPv4GatewayAddr
$send_flag $confirm $output
$clish_sw(ProductID) $verch]} result]} {
log_info "FAILED: Error in executing
run_command_set_setup_system_ipv4 $result!!"
} else {
exp_continue
}
}


SCRIPT B:
proc run_command_set_setup_system_ipv4 {lspawn_id EthIPv4NetworkEnbl
EthIPv4NetworkDisc
EthIPv4NetworkAddr EthIPv4NetworkMask EthIPv4GatewayAddr
send_flag confirm output {Hardware ""}
{Version ""}} {
..
..
..

if {[string compare -nocase $send_flag "True"] == 0} {
send -i $lspawn_id "set setup system ipv4\r"
} else {

}
expect {

}

Cameron Laird

2007-08-25, 7:18 pm

In article <1188037886.266240.244000@m37g2000prh.googlegroups.com>,
Swaroop <swaroop.tata@gmail.com> wrote:
>Hi,
> I have the peace of code like this. i am calling a proc from Script
>A. in script A if i set send_flag to False, in the script B, the send
>command should not work. I am calling the proc in script B with
>send_flag set to false, but i want the expect block to be executed.
>The problem is when i am not sending anything, the control is not
>going to the expect block. If i want the expect block to be executed
>can i send "send -i $lspawn_id "" ".?
>
>
>SCRIPT A:
>
>"EthIPv4NetworkEnable" {
> if {[catch {set rc [run_command_set_setup_system_ipv4 $lspawn_id
>$EthIPv4NetworkEnbl
> $EthIPv4NetworkDisc $EthIPv4NetworkAddr
>$EthIPv4NetworkMask $EthIPv4GatewayAddr
> $send_flag $confirm $output
>$clish_sw(ProductID) $verch]} result]} {
> log_info "FAILED: Error in executing
>run_command_set_setup_system_ipv4 $result!!"
> } else {
> exp_continue
> }
> }
>
>
>SCRIPT B:
>proc run_command_set_setup_system_ipv4 {lspawn_id EthIPv4NetworkEnbl
>EthIPv4NetworkDisc
> EthIPv4NetworkAddr EthIPv4NetworkMask EthIPv4GatewayAddr
>send_flag confirm output {Hardware ""}
> {Version ""}} {
>.
>.
>.
>
> if {[string compare -nocase $send_flag "True"] == 0} {
> send -i $lspawn_id "set setup system ipv4\r"
> } else {
>
> }
>expect {
>
>}
>


I'm lost. The code you've presented appears to be truncated occasionally,
and erratically indented. As near as I can tell, A vs. B is irrelevant to
what you're trying to communicate.

I almost understand your question, though:
The problem is when i am not sending anything, the
control is not going to the expect block. If i
want the expect block to be executed can i send
send -i $lspawn_id ""
?
(reformatted for clarity). Yes, you can {send ... ""}; it won't help
achieve what you're after, though.

I'm confident "control is not going to the expect block" because Expect
has not detected the input pattern you've specified. Expect does what
you tell it. I don't understand what you want to do, so I don't feel
in a position to tell you what input pattern you should specify to
Expect.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com