Expect + grep



Hi

I have written a GUI tool which issues commands on remote hosts using
Expect. The tool displays everything that is returned as a result of
“send …\r”. It works very well except when using ’grep’. I found in
c.l.t. some discussions on the issue of Expect-grep (mis)match, but I
am still unsatisfied…
The problem, as before, is that I don’t always get back all the data
which’ grep’ generates.

What I don’t understand is that Expect simulates an interactive CLI.
In such a case, when a host returns the prompt, the command (buffering
or not) finished running and by then displayed all of its output. But
according to previous postings on the subject, this is not always the
case when Expect is used. Also, depending on the amount of data
generated, only one of the following seems to work:

-re "(\\\$|.*bash.*)" {
# exp_send_user "\nPrompted\n"
return
}

-re "(\[^\r]*)\r\n" {
# display line:
send_user "\nLINE: <$expect_out(1,string)>\n"
exp_continue
}

OR:

full_buffer {
# send_user "FULL BUFFER\n"
append buffer $expect_out(buffer)
exp_continue
}

-re "(\\\$|.*bash.*)" {
# exp_send_user "\nPrompted\n"
return
}
}
(parse $buffer and display)

Is the Expect + grep a battle not worth fighting? I can use a
workaround, such as:
ssh host “grep xyz /a/b/c” > local_file
and display the file content but that would necessitate a separate
Expect script (I want to keep using the generic Expect script which
executes _any_ command remotely).

Thanks
Avi
.



Relevant Pages

  • Re: Expect + grep
    ... I have written a GUI tool which issues commands on remote hosts using ... It works very well except when using ?grep?. ... In such a case, when a host returns the prompt, the command (buffering ...
    (comp.lang.tcl)
  • Re: Anyone remember DOS?
    ... Trying to see if anyone knows the command I'm looking for without ... and *) can be used to specify groups of files. ... When you use the DIR command, it will display all files that match the ... To display only files with the .TXT filename extension on the current ...
    (rec.music.artists.springsteen)
  • Re: using the command prompt
    ... Is there a tutorial on using the command prompt to complete ... That will display a list of all ... CD Change Directory - move to a specific Folder. ... DSACLs Active Directory ACLs ...
    (microsoft.public.windowsxp.general)
  • Re: Display problems in Vista
    ... Very small overhead. ... the command packet needs to be transfered. ... have to display a line that is x pixels wide at any zoom level. ...
    (comp.graphics.api.opengl)
  • Re: Read Only / Thanks Keith.
    ... >'attrib' without any parameters will display a directory ... >The full syntax of the command follows (pasted from Help ... Used without parameters, attrib displays ... xcopy command uses archive attributes. ...
    (microsoft.public.windowsxp.general)