English 中文(简体)
(Tcl/Expect) clear screen after exit
原标题:

I want to clear the screen (on the local machine) after exiting from my (semi) interactive expect script. Can I do that from within the script? Here s what I tried, that failed.

#!/usr/bin/expect -f
set env(TERM) vt100
spawn ssh -Y username@domain
set user username
set pass password 
#login sequence
expect "password: "
send "${pass}
"
sleep .5  
#some menu commands to enter ERP....
#...
#...
set CTRLZ 32
set CTRLC 03
set CTRLA 01
#don t time out
set timeout -1 
        interact {
                -reset $CTRLZ {exec kill -STOP [pid]}
                $CTRLA   {   
                        exp_send "menucmd...
y
"
                }   
                $CTRLC   {  

                        #clear the host machine screen???
                        exec clear
                        exit
                }
                ~~  
        } 

On the remote side I m not in a shell but in an ERP program. I could exit to the shell then do a "clear" on the remote host if that s what s necessary, but I think the remote host prompt would still be on the screen.

EDIT: changed to try clear before "exit" (sub-question: "exec clear" is executed on the machine running the expect script right?)

最佳回答

Once you [exit], everything else after is not going to be executed. You should [exec clear] before exiting.

If you re using a vt100 compatible terminal (and most Unix terminals are) then you can try directly sending vt100 commands to the terminal:

puts 33[2J
问题回答

暂无回答




相关问题
Interactive architectural diagram tools [closed]

Are there any tools that would allow me to easily create an interactive architectural diagram? I envisage the ability to view a graphical depiction of the architecture at a high level. I would then ...

Interactive Design-Time User Control

I apologise if the title was confusing, it took me nearly 5 minutes to finally think of a title for this one... Okay, you know how in Visual Studio Express when you add a TabControl to the Form, and ...

Hosting .fsx scripts inside larger applications

I want to expose my F# libraries as a scriptable tool for data manipulation. Optimally, I want this scripting facility to not require a full F# install with fsi and so on. Is there a way to link ...

Interactive Python GUI

Python have been really bumpy for me, because the last time I created a GUI client, the client seems to hang when spawning a process, calling a shell script, and calling outside application. This ...

(Tcl/Expect) clear screen after exit

I want to clear the screen (on the local machine) after exiting from my (semi) interactive expect script. Can I do that from within the script? Here s what I tried, that failed. #!/usr/bin/expect -f ...

git rebase interactive: squash merge commits together

I wanted to have a simple solution to squash two merge commits together during an interactive rebase. My repository looks like: X --- Y --------- M1 -------- M2 (my-feature) / / ...

热门标签