您的位置:首页 > 其它

打卡25: expect interact for tow process

2014-10-23 17:10 148 查看
inject_wise: ----------------it call connect_wise :

set CW "connect_wise -c $COOLXDIR -pn 2 -f $RCSCELL"

spawn -open [open "| $CW" "w+"]

sleep 1

exp_send "$CMD\r"-------------------------------after start connect_wise ,send info to connect_wise ,connect_wise use interact to receive

sleep 3

connect_wise :

set outpipe_name $COOLXDIR/.${filePrefix}${coolwin}_$pipe_num.inpipe

set inpipe_name $COOLXDIR/.${filePrefix}${coolwin}_$pipe_num.outpipe

interact {

-input $user_spawn_id

eof {

#puts stdout "Hit eof of input"

exit

}

"" {

puts stdout "User requested exit"

exit

} -output $outpipe

-input $inpipe eof {

puts stderr "EOF from attached TTY"

exit

} -output $user_spawn_id

}

user_spawn_id---> outpipe

inpipe-->user_spawn_id

function:

input message in one ap term ,it will not only show in ap term ,but also in wise window,

two windows show the same together and at the same time

interact: wait for other process ,exp_send

user_spawn_id standard input and standard output

The -input flag identifies a spawn id from which input should be read. The -output flag identifies a spawn id to which output should be written

-input and -output can use multiple process

read from input pipe , write to output pipe

pile is special file ,input one line ,then read one line at the same time then next sentence

spawn for write and pipe file :

Expectsnormally uses spawn to invoke a program. It can look at the programsoutput and input data into the program.

Expectcan also use spawn to open a file but treat it as if it is a spawned program. That would be spawn –open [open <file> <mode>]. The<mode> indicates if expect will be reading from the file or writing toit.

Insteadof just opening a file, expect can also open a pipeline to or from a givenprogram. That would be spawn –open [open “| <program>”<mode>]. In this situation, the interface between expect and the programis only one-way. Either expect is inputting data
into program (if themode was “w” or “w+”) or expect is reading from the program (mode is “r”).

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

interact {

-input $user_spawn_id -output $spawn_id

-input $spawn_id -output $user_spawn_id

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: