Re: [Expect] Scripting SSH with Activestate Expect and TCL...'?' chars inserted in terminal
by asilver other posts by this author
Jun 27 2008 2:49PM messages near this date
view in the new Beta List Site
Re: [Expect] Scripting SSH with Activestate Expect and TCL...'?' chars inserted in terminal
|
[Expect] Calling Expect Script Using Exec in PHP
The properties says this is version 5.43.2.0 (filename expect543.dll). I
myself have not been able to reproduce this. The customers that I support
are seeing this and can reproduce it. I thought it was something
originally with plink only, so I had my customers try vsh (ClientPack from
Vandyke Software). The problem does not happen with vsh but I'd like to
use plink so customers do not have to purchase additional windows ssh
client. However, while researching this, I saw the note below where it
happens with openssh client as well. Just trying to get to the bottom of
this.
Note, the version of expext I'm using is not the latest one that has the
DEP fix, as some customers have to disable DEP in order to get the scripts
wrapped by TCLapp to work.
Thanks
al
> I've seen this report before. I'd like to know if it occurs in the
> 5.39.1 (the dll will report this in Properties) that fixed the other DEP
> issues.
>
> It may simply be a Windows-only bug of the Expect port, but given the
> way in which it moves, it may be something else, like a logic bug, or
> not stripping some ANSI-type codes right, etc.
>
> Jeff
>
> asilver@[...].com wrote:
> > I saw this on the google TCL group because I am experiencing the same
> > exact problem. Thought it was a good idea to post here as well:
> >
> >
> > I'm experiencing the same exact problem sending to a Cisco router. I'm
> > also using plink. The character "?" only occasionally gets inserted out
> > of nowhere?? I've tried experimenting with the Expect send_slow
> > variable
> > (send_block and send_delay) with a little bit of improvement but this
> > problem still creeps up. I've never seen this happen when using telnet,
> > only ssh. Was there ever a resolution to this issue??
> >
> > Thanks
> > Al
> >
> > ccly...@[...].com wrote:
> >> I'm new to tcl, expect, and coding from a windows environment ;) I am
> >> using ctivestates distribution of Expect and TCL on a Windows XP host
> >> with PuTTY's Plink tool, attempting to connect to Sun Solaris boxes
> >> using openssh. My goal here is very simple: I want to automate
> >> sshing to a list of IPs, and execute the same series of commands on
> >> each machine. Some of these commands require sudo, so I have to pass
> >> a password to that as well.
> >>
> >> I have the script below working to read through the list of IPs and
> >> login to each one. I have it passing the password to sudo properly.
> >> However, I'm getting some weirdness with the output. It should be
> >> passing something like:
> >>
> >> sh -c 'echo \"HISTORY=5\" >> /etc/default/passwd'
> >>
> >> However it keeps inserting ? characters, so what I get is more like:
> >>
> >> sh -c 'echo \"HISTORY=5\" >> /etc/default/p?asswd'
> >>
> >> I suspect my issue has to do with some fundamental misunderstanding on
> >> my part about how to deal with spawning processes and subprocesses in
> >> TCL/Expect. Please help if you can...what I want SEEMS like it should
> >> be so trivial, yet I'm completely hung up here.
> >>
> >> #!/bin/sh
> >> # >>> exec tclsh "$0" ${1+"$@"}
> >>
> >> package require Expect
> >>
> >> # Turn off echo logging to the user by default exp_log_user 1
> >> exp_internal 1
> >>
> >> # This is the magic timeout variable used by Expect (time in seconds).
> >> set timeout 10
> >>
> >> # We want to operate very simply - force a dumb terminal mode set
> >> env(TERM) dumb
> >>
> >> set ::exp::winnt_debug 1
> >>
> >> set timestamp [clock format [clock seconds]] set ip [open ips.txt] set
> >> exp_log_file login.log
> >>
> >> # The default option settings
> >> array set OPTS {
> >> user "MYUSER"
> >> password "MYPASS"
> >> prompt "(%|#|>|\\$) $"
> >> command "sudo chmod 777 /etc/default/passwd"
> >> }
> >>
> >> while {[gets $ip line] >=0 } {
> >> set pid [spawn Plink.exe $line -l $OPTS(user) -pw $OPTS(password)]
> >> set id $spawn_id
> >> set logged_in 0
> >> while {!$logged_in} {
> >> # Handle SSH host key dialog
> >> expect -re "(\[Yy\]es\/\[Nn\]o).*" {
> >> exp_send "yes\r"
> >> }
> >> expect -re "(\[Yy\]\/\[Nn\]).*" {
> >> exp_send "y\r"
> >> }
> >> expect -re $OPTS(prompt) {
> >> set logged_in 1
> >> }
> >> }
> >>
> >> if {$logged_in} {
> >> # expect -re $OPTS(prompt)
> >> # Run command with sudo
> >> exp_send "$OPTS(command)\r"
> >> expect -re "\[Pp\]assword:\r"
> >> exp_send "$OPTS(password)\r"
> >> exp_send "sh -c 'echo \"HISTORY=5\" >> /etc/default/passwd'\r"
> >> exp_send "sudo chmod 444 /etc/default/passwd\r"
> >> expect -re "\[Pp\]assword:\r"
> >> exp_send "$OPTS(password)\r"
> >> exp_send "tail /etc/default/passwd\r"
> >> }
> >> exp_close -i $id
> >> exp_wait -i $id
> >> }
>
>
_______________________________________________
Expect mailing list
Expect@[...].com
http://listserv.ActiveState.com/mailman/listinfo/expect
Thread:
asilver
Jeff Hobbs
asilver
|