http://www.perlmonks.org?node_id=136508

Bloodelf has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to use a perl script to open a Windows NT hyperterminal session, and then pipe information from a file into this session. Playing around with other processes is completely new to me and I'm not even sure if it's possible to do what I want to do. If it is, could someone point me in the right direction…..
Cheers

Replies are listed 'Best First'.
(jcwren) Re: Use perl to communicate With a windows application
by jcwren (Prior) on Jan 05, 2002 at 20:17 UTC

    I won't comment on what you're trying to do so much as using HyperTerminal to do it.

    I do a LOT of work that involves talking to serial devices, both from Windows (DOS mode and Win32 apps) and from Linux (both C and Perl).

    Regardless of how you feel about Windows, HyperTerminal is the biggest piece of crap to have ever been included on a CD. It is a complete and total waste of disk space, CPU time, and your time. HyperDooDoo (as we're fond of calling it), has been responsible for more wasted time with clients than ANY OTHER SINGLE ITEM. We've had several clients that rather than trying to teach them to use HyperDooDoo, we Fedex them a copy of Procomm. And trying to teach someone to use HyperDooDoo over the phone can be next to impossible.

    HyperDooDoo hangs when hardware flow control is missing, it has bugs in the file transfer protocols, in the terminal emulation, and in a word, sucks. It is inflexible and a general pain in the ass to use.

    I absolutely cannot believe that Microsoft includes this garbage on the CD. Or (despite how you may feel about the inherent quality of Windows) that it ever got past Quality Assurance at Microsoft. I've seen better apps written by 14 year olds as their first program.

    So unless you have the rest of your life to waste trying to debug their code for them, don't use it. Procomm, Kermit, or any of the other several dozen public domain programs will serve you far better. And when you're debugging, at least you can be 99% assured that the code that's flawed will be yours.

    --Chris

    e-mail jcwren

Why use hyperterminal?
by metadoktor (Hermit) on Jan 05, 2002 at 19:57 UTC
    Why not use Kermit instead? It's reasonably fast, flexible, command-line and script oriented, implements not only basic serial communications but also telnet and ftp and is available for nearly every platform in existence.

    See www.columbia.edu/kermit for more info.

    metadoktor

    "The doktor is in."

Re: Use perl to communicate With a windows application
by jmcnamara (Monsignor) on Jan 06, 2002 at 04:01 UTC

    The Win32::GuiTest module might do what you want.

    It uses SendKeys to send keystrokes and mouse events to Windows applications.

    Although, if you just want to simulate a telnet session with a remote host there are probably better ways to do it.

    --
    John.

Re: Use perl to communicate With a windows application
by gri6507 (Deacon) on Jan 06, 2002 at 08:02 UTC
    I cannot comment on functionality of HyperTerminal (or HyperDooDoo as another Monk has kindly called it), but if you are simply trying to automate a serial communicatino session, you may be better off using a Kermit like application. Likewise, if you are well versed in Perl, look into Win32::SerialPort and you will have FULL control over what happens when (and how).

    Finally, if all you are trying to do is to send a few bytes here and there without any serial protocol, you can even open up the Port with this code

    sysopen(COM,COM1,O_RDWR) || die "Can't open COM1 $^E";
    and use these commands to write and read to the port
    #code to send data to port syswrite(COM,$string); #sends $string to COM1 #code to read data from port sysread(COM,$buf,$length); #read $length bytes $received = unpack("C*",$buf); #unpack them

    Hope this helps.