[WindyCity-pm] Expect-style interaction between processes

Knight, Brian Brian.Knight at us.mizuho-sc.com
Fri Feb 27 09:19:02 PST 2009


I am working on a project which involves pulling a configuration file off of
a legacy system through an RS-232 connection.  For transferring that file,
the legacy system supports only the XMODEM-CRC file transfer protocol.

The legacy system is attached to our serial console server, which is far more
modern and supports SSH.  The host running the scripting tasks is a RHEL 4
box.

Unfortunately the XMODEM-CRC part is not negotiable as it's a legacy system,
but the SSH connection could be converted to telnet in a pinch.

There's also some amount of send/expect scripting to do in order to tell the
system to transfer that file.  That part is easy enough.  Where I am having
trouble is, when the system is ready to send the file, I can't hand-off that
SSH connection to the XMODEM receive process.  Expect 5.42.1's "interact -u"
behavior seems to be somewhat broken, and I'm looking for another way to do
it.

Another facet of the problem is that, once the XMODEM receive is done, I need
the script to retake control of the SSH process to log off of the legacy box.

But the problem isn't with SSH; it's definitely with "interact -u".  I have
an Expect test script that literally connects a local XMODEM send process
with a local XMODEM receive process, and it doesn't work:
---------------------------------------
spawn sx -q testfile1.bin
set term_id $spawn_id
expect "XMODEM"
spawn rx -qy testfile2.bin
expect -re "rx: ready to receive.*\r\n"
interact -u $term_id
set spawn_id $term_id
---------------------------------------

I'm able to run "mkfifo ./testpipe; sx -q testfile1.bin < testpipe | rx -q
testfile2.bin > testpipe" and that works perfectly fine, so I know my XMODEM
tools aren't broken.

Any pointers on Perl modules or methods that might help attach and detach
these processes, or might help with the entire task?

Thanks,

-Brian Knight
Sr. Network Engineer
Mizuho Securities USA, Futures Division
http://www.mizuho-sc.com/

* Please note that I do not speak for my employer - only for myself.

CONFIDENTIAL: This e-mail, including its contents and attachments,
if any, are confidential. It is neither an offer to buy or sell,
nor a solicitation of an offer to buy or sell, any securities or
any related financial instruments mentioned in it. If you are not
the named recipient please notify the sender and immediately delete
it. You may not disseminate, distribute, or forward this e-mail
message or disclose its contents to anybody else. Unless otherwise
indicated, copyright and any other intellectual property rights in
its contents are the sole property of Mizuho Securities USA Inc.
     E-mail transmission cannot be guaranteed to be secure or
error-free. The sender therefore does not accept liability for any
errors or omissions in the contents of this message which arise as
a result of e-mail transmission.  If verification is required
please request a hard-copy version.
     Although we routinely screen for viruses, addressees should
check this e-mail and any attachments for viruses. We make no
representation or warranty as to the absence of viruses in this
e-mail or any attachments. Please note that to ensure regulatory
compliance and for the protection of our customers and business, we
may monitor and read e-mails sent to and from our server(s).
#####################################################################################


More information about the WindyCity-pm mailing list