Re: expect script doesnt pass graphics chars correctly



Ok, thanks for that. In the end I managed to solve my problem using 'empty' in a bash shell script. Much simpler than expect, but it does what I need.

Jeremy


vitic wrote:
On May 19, 7:07 am, Jeremy Cook <jeremy.c...@xxxxxxxxxxx> wrote:
Hi folks,

My expect script needs to automate login to a terminal server which is
running a text based interface. The text based program assumes "scoansi"
terminal type and "ibm850" character encoding.

When I carry out the login steps by hand everything works beautifully
and the ansi graphics look good (well as good as it gets...). However
when I try to automate this with expect, something is going wrong with
the terminal emulation/setup/whatever and the graphics characters do not
show properly. I feel it must be some sort of tty mode issue, but have
not been able to find a solution. Any and all comments are welcome.

A transcript of my script:

#!/usr/bin/expect -f
spawn -nottyinit ssh -t some...@xxxxxxxxxxxx
set ssh $spawn_id
expect "*?assword: "
send -- "yadayada\r"
expect "\u0005"
stty -echo
send -- "okydoky\r"
stty raw -echo
interact -reset -output $ssh

Now I can interact, but all of the graphics chars are garbled.

eg ?Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"Ã"
instead of -----------------

Any ideas? Or can I jump out of expect somehow at the end (I dont need
it anymore once the last send has been done).

Jeremy


About 5 years ago I used expect to automate terminal based SAP
administration. I had the same problem with the ANSI terminal and as
far I can remember now, there was no way around it. What you see on
the screen is not what Expect sees. The terminal driver translates the
characters to be suitable for your screen and you don't see any
control sequences but Expect does. Also, the drawing of the text on
the terminal screen does not always happen sequentially (any part of
the screen can be repainted at any time by the terminal driver).
Meanwhile, expect reads everything sequentially. What I have done is
discard irrelevant data and only look for distinct peaces of relevant
data. It is somewhat a brute force programming and is not very exact,
although it worked just fine for me. First, use the autoexect script
to record your entire session and then modify the captured session to
suit your needs. The Expect book also mentions the same problem and
the advice has been similar to what I have done, as far as I can
remember.

Hope that helps,

---Victor
.



Relevant Pages

  • Using hashes to sort number sequences
    ... I posted to comp.lang.perl for help with a script ... Each file contains in the first column an identifier, ... and search for similar number sequences in file b.txt. ... # Perl script to compare to files with T6 CS & VS ...
    (comp.lang.perl.misc)
  • Re: Perl script to mimic uniq
    ... >> How can I still keep the identifier part of the line linked to the array? ... >> So I'm back to my original script which looks like this. ... If there are duplicate sequences ... I only loop over the sequences which are indexed as 'not ...
    (comp.lang.perl)
  • Re: SQL insert/update duplicate entries
    ... I did end up making up a script ... > is the one that I am using to identify sequences of interest. ... I'd consider forgetting the identifiers for the moment. ... > I suppose I could make a Perl script to anaylze the table, ...
    (comp.lang.perl.misc)
  • Re: SQL insert/update duplicate entries
    ... I did end up making up a script ... > If that is incredibly inefficient, ... >> is the one that I am using to identify sequences of interest. ... > I'd consider forgetting the identifiers for the moment. ...
    (comp.lang.perl.misc)
  • Re: pppd pty equivilent in FBSD
    ... I let pppd manage retries & setting routes. ... >I wouldn't personally recommend vpn over ssh for anyone either, ... I'm the sole bsd user at my company, and the ppp over ssh ... >Actual bash script I call: ...
    (freebsd-net)