Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

TCL(Tool Command Language) Scripting

Using Exec rather than spawn expect to redirect stdout

Okay, I'm still trying to workaroung getting a loud BELL everytime there is
an error n my expect/telnet script. The script works well except for this.

I posted a question a few days ago asking if anyone knew how to avoid gettng
the BELL everytime expect gets an error. One of the suggestions is
interesting. Someone suggested using "exec telnet.exe" rather than "spawn
telnet.exe". The poster said that I could possible use exec because it
supports redirection and at the sane time I could use telnet interacrively
with expect. Well, how do I do ths? Does anyone else have a suggestion how
to avoid the BELL when expect gets an error. (or a million bells if there
are a million erros).

1) exec telnet.exe 2> errorFile.txt
Result doesn't work  this gets error "child process ..."

2) exec telnet.exe 2> errorFile.txt &
This runs it in the background but how do I send a command through expect
with this?

- Daniel

Posted via a free Usenet account from http://www.teranews.com

On May 28, 12:14 pm, dani@hereIam.com wrote:

Are you sending any output to the user using puts or send_user. If you
are then strip out the bell
using :
set buffer "this is a bell:\u0007"
puts $buffer ; # should hear bell
regsub {\a} $buffer "" buffer
puts $buffer; # no bell should be heard


On May 28, 12:14 pm, dani@hereIam.com wrote:

Oh yeah before I forget. If you set the log_user to 1 you will get all
the output sent to the user
directly. In which case you cannot intercept the Cntrl-A (Bell). You
need to set that to 0 i.e
log_user 0
.... expect script ....
<script end>

This means that you will have to pepper your script with your own
output statements if
you were monitoring via log_user.  You can set up a proc to do the
output and filter any
bells from the output.

proc userlog { buffer } {
   regsub {\a} $buffer "" buffer
   send_user "$buffer"


and in your script as an example  ....

log_user 0
expect {
      -i $spawnid
      -re {assword: } {
                  userlog $expect_out(buffer);
                  exp_send -i $spawnid "mypassword\r"
      -re {.*Invalid Password!} {
               # invalid password bells are going off
              userlog $expect_out(buffer); # but not anymore
              send_user "Unable to login"
       ..... <eof and timeout handlers>


Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc