Re: [foxboro] som and rsom

You can open a process for reading and writing from Perl.

Here's an example of using open2():
     use FileHandle;
     use IPC::Open2;
     $pid = open2(*Reader, *Writer, "cat -u -n" );  # replace with som or 
rsom command
     print Writer "stuff\n";
     $got = <Reader>;
The problem with this is that Unix buffering is really going to ruin your 
day. Even though your Writer filehandle is auto-flushed, and the process on 
the other end will get your data in a timely manner, you can't usually do 
anything to force it to give it back to you in a similarly quick fashion. 
In this case, we could, because we gave cat a -u flag to make it 
unbuffered. But very few Unix commands are designed to operate over pipes, 
so this seldom works unless you yourself wrote the program on the other end 
of the double-ended pipe.
A solution to this is the nonstandard Comm.pl library. It uses pseudo-ttys 
to make your program behave more reasonably:
     require 'Comm.pl';
     $ph = open_proc('cat -n');
     for (1..10) {
         print $ph "a line\n";
         print "got back ", scalar <$ph>;
     }
This way you don't have to have control over the source code of the program 
you're using. The Comm library also has expect() and interact() functions. 
Find the library (and we hope its successor IPC::Chat) at your nearest CPAN 
archive as detailed in the SEE ALSO section below.



>You can have som and rsom read from an ascii command file with the -i
>option.
>Type "som -h" ot "rsom -h" for more detail.
>Don't forget to put the "q" for quit at the end of the command file,
>otherwise, som/rsom will hang.
>
>
>Regards,
>Mark Dumond
>FeedForward, Inc
>
>
>
>-----Original Message-----
>From: foxboro-bounce@xxxxxxxxxxxxx
>[mailto:foxboro-bounce@xxxxxxxxxxxxx]On Behalf Of duc.do@xxxxxxxxxxxxxx
>Sent: Wednesday, October 23, 2002 11:29 AM
>To: foxboro@xxxxxxxxxxxxx
>Subject: [foxboro] som and rsom
>
>
>
>Hi list
>
>I use som and rsom occasionally, but every time I do, I wish there's a
>command-line method (non-interactive) to produce the same output, without
>having to type 'opdb', 'opvr xx', and 'm opvr', repeatedly. Is it possible?
>Alex?
>
>Thanks!
>
>Duc
>
>--
>Duc M. Do
>Dow Corning Corp.
>Carrollton Plant
>Carrollton, KY, US
>
>________________________________________________________________________
>This email has been scanned for all viruses by the MessageLabs SkyScan
>service. For more information on a proactive anti-virus service working
>around the clock, around the globe, visit http://www.messagelabs.com
>________________________________________________________________________
>
>
>_______________________________________________________________________
>This mailing list is neither sponsored nor endorsed by Invensys Process
>Systems (formerly The Foxboro Company). Use the info you obtain here at
>your own risks. Read http://www.thecassandraproject.org/disclaimer.html
>
>foxboro mailing list:             http://www.freelists.org/list/foxboro
>to subscribe:         mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
>to unsubscribe:      mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
>
>
>
>
>_______________________________________________________________________
>This mailing list is neither sponsored nor endorsed by Invensys Process
>Systems (formerly The Foxboro Company). Use the info you obtain here at
>your own risks. Read http://www.thecassandraproject.org/disclaimer.html
>
>foxboro mailing list:             http://www.freelists.org/list/foxboro
>to subscribe:         mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
>to unsubscribe:      mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
>

Winston Jenks
Technical Director, Cape Software, Inc. 

 
 
_______________________________________________________________________
This mailing list is neither sponsored nor endorsed by Invensys Process
Systems (formerly The Foxboro Company). Use the info you obtain here at
your own risks. Read http://www.thecassandraproject.org/disclaimer.html
 
foxboro mailing list:             http://www.freelists.org/list/foxboro
to subscribe:         mailto:foxboro-request@xxxxxxxxxxxxx?subject=join
to unsubscribe:      mailto:foxboro-request@xxxxxxxxxxxxx?subject=leave
 

Other related posts: