expect: bs and del don't work 
Author Message
 expect: bs and del don't work

What am i doing wrong here?
I am trying to control an application where i want to delete two
characters to the left.  so i wrote the following test program (which
doesn't work):

#!/usr/local/bin/expect
set bs \010
set del \177
puts "anything$bs\r"
puts "anything$del\r"

i was hoping for the following:
anythin

but instead i get:
anything

Mike
--
Mike Yockey
Systems Engineer
Sony Semiconductor



Mon, 09 Aug 1999 03:00:00 GMT  
 expect: bs and del don't work

Quote:

> What am i doing wrong here?
> I am trying to control an application where i want to delete two
> characters to the left.  so i wrote the following test program (which
> doesn't work):

> #!/usr/local/bin/expect
> set bs \010
> set del \177
> puts "anything$bs\r"

> i was hoping for the following:
> anythin

> but instead i get:
> anything

> Mike
> --
> Mike Yockey
> Systems Engineer
> Sony Semiconductor


Looks to me like you write 'anything and do a BS so the cursor is
positioned. Thes you write it out again 'and del the char at the end.

What about  puts "anything[set bs][set del]\r"



Tue, 10 Aug 1999 03:00:00 GMT  
 expect: bs and del don't work

Quote:

> What am i doing wrong here?
> I am trying to control an application where i want to delete two
> characters to the left.  so i wrote the following test program (which
> doesn't work):

> #!/usr/local/bin/expect
> set bs \010
> set del \177
> puts "anything$bs\r"
> puts "anything$del\r"

> i was hoping for the following:
> anythin

> but instead i get:
> anything

> Mike
> --
> Mike Yockey
> Systems Engineer
> Sony Semiconductor


I am not sure exactly what you are wanting, but this might work for you.
You could set up a procedure to remove one (or more) characters from the
end.  This is Tcl code, and is not unique to working in expect.

proc RemoveEndChar {somestring} {
  set somestring [string range $somestring 0 \
    [expr [string length $somestring] -2]]
  return $somestring

Quote:
}

% set myvar [RemoveEndChar anything]
anythin
%

--
Ron Riesenberger                The opinions within this message are
Edward Jones & Co.              my own and in no way should be
St. Louis, MO. U.S.A.           considered the views of my employer.
UNIX System Administration

  "A day without laughter is a day wasted."  -- Charlie Chaplin



Tue, 10 Aug 1999 03:00:00 GMT  
 expect: bs and del don't work

Quote:

> What am i doing wrong here?
> I am trying to control an application where i want to delete two
> characters to the left.  so i wrote the following test program (which
> doesn't work):

> #!/usr/local/bin/expect
> set bs \010
> set del \177
> puts "anything$bs\r"
> puts "anything$del\r"

> i was hoping for the following:
> anythin

> but instead i get:
> anything

> Mike
> --
> Mike Yockey
> Systems Engineer
> Sony Semiconductor


I tried your script inside Emacs and got the following:

anything^H^M
anything^?^M

What I believe is happening here is that the output you are sending is
not actually associated with a tty - puts just sends it to stdout and stdout
views backspace and delete as just another byte of data.  When you send
data to a process spawned by expect, it is associated with a tty and the
terminal driver does what you expected.  When I try the following example:

#!/usr/local/bin/expect

set bs \010
set del \177
spawn cat
send "anything$bs\r"
send "anything$del\r"
expect eof

I get:

spawn cat
anything^H
anythin
anything
anythin

--

University of Colorado, Boulder



Wed, 11 Aug 1999 03:00:00 GMT  
 expect: bs and del don't work


:>
:> What am i doing wrong here?
:> I am trying to control an application where i want to delete two
:> characters to the left.  so i wrote the following test program (which

:I am not sure exactly what you are wanting, but this might work for you.

He is needing to transmit backspace and/or delete characters to an
interactive applications.

--

<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.



Thu, 12 Aug 1999 03:00:00 GMT  
 expect: bs and del don't work

: What am i doing wrong here?
: I am trying to control an application where i want to delete two

Something similar:

In an interactive application, when I enter
typi <bs> o
the interactive screen shows :
typo

To the application is also sent: "typo", because i mapped the
bs (\x08) key to:
send "\010\240\010"

the log_file however shows:
typi o

So only the log_file is a bit scrambled
Is there a fix for it?



Mon, 16 Aug 1999 03:00:00 GMT  
 expect: bs and del don't work

Theo,

actually, i suspect it's just fine- the log file is reflecting the
actual characters sent in order.  the space actually is a backspace
unprintable character. (or translated to a space for viewing by more).
this is similar to the behavior of the unix "script" command, which
scripts a terminal session.

Mike

Quote:


> : What am i doing wrong here?
> : I am trying to control an application where i want to delete two

> Something similar:

> In an interactive application, when I enter
> typi <bs> o
> the interactive screen shows :
> typo

> To the application is also sent: "typo", because i mapped the
> bs (\x08) key to:
> send "\010\240\010"

> the log_file however shows:
> typi o

> So only the log_file is a bit scrambled
> Is there a fix for it?

--
Mike Yockey                           Systems Engineer

--== All opinions expressed are mine, except where indicated. ==--


Fri, 20 Aug 1999 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Expect + pppd sometimes don't work

2. simple math don't work like I expected

3. Why don't some programs work with expect

4. Dolphin Applet's don't work...

5. match works, don't match doesn't

6. UNC's Still Don't Work?#$%

7. Help with parsing a file and don't obtain the expected results

8. Counter slows down when the number of the expected pulses don't arrive

9. Counter slows down when the number of the expected pulses don't arrive

10. re.LOCALE | re.IGNORECASE doesn't work as you'd expect

11. Expect and Don Libe's Top award this past century

12. expect's full_buffer doesn't seem to work

 

 
Powered by phpBB® Forum Software