473,604 Members | 2,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IPC::Run and hanging pipes

I am attempting to write an application that uses the expect binary to
get info off a telnet session. At first this app was written in
mod_perl under perl 5.005_03 using Expect.pm but we're moving it to
5.6.1 to take advantage of custom security and authentication and
Expect no longer works (similar to the IPC::Open2(3) problems under
mod_perl).

I am in the process of making the code use IPC::Run to call the expect
binary and use pipes to read and write data multiple times during a
session but I am having a problem where the read pipe just hangs, no
output and it never ever comes out of it unless I add a timeout. This
is on Solaris 8. Here is the example code:

#!/usr/bin/perl -w

use IPC::Run qw( start pump finish timeout run );

local(*Reader, *Writer, *ERR);

my @expect = qw( expect - );

my $h = start
\@expect,
'<pipe', \*Writer,
'>pipe', \*Reader,
'2>pipe', \*ERR, $t = timeout( 10 )
or die "expect returned $?" ;

warn "Starting first write\n";

print Writer qq~
exp_internal 1;
set timout 30\;
spawn telnet system

sleep 2

puts "NEXT"
~;

while (<Reader>) { last if /NEXT/; warn "READ\n"; print; }

warn "1\n";

It never gets past the while loop and it never puts out the READ warn
or any data either. I have tried moving this to use readline() in
both scalar and list context with the same results. Is there ANY way
to figure out why this is happening or to get data come back? I had
luck with IPC::Open2 but obviously I can't use that anymore under
mod_perl.
Jul 19 '05 #1
1 7364
Well I ended up modifying it to use scalar refs and pump() and it
works now. Do pipes just NOT work in mod_perl anymore?

c0***@beatdowns quad.com (Brian Hann) wrote in message news:<35******* *************** ****@posting.go ogle.com>...
I am attempting to write an application that uses the expect binary to
get info off a telnet session. At first this app was written in
mod_perl under perl 5.005_03 using Expect.pm but we're moving it to
5.6.1 to take advantage of custom security and authentication and
Expect no longer works (similar to the IPC::Open2(3) problems under
mod_perl).

I am in the process of making the code use IPC::Run to call the expect
binary and use pipes to read and write data multiple times during a
session but I am having a problem where the read pipe just hangs, no
output and it never ever comes out of it unless I add a timeout. This
is on Solaris 8. Here is the example code:

#!/usr/bin/perl -w

use IPC::Run qw( start pump finish timeout run );

local(*Reader, *Writer, *ERR);

my @expect = qw( expect - );

my $h = start
\@expect,
'<pipe', \*Writer,
'>pipe', \*Reader,
'2>pipe', \*ERR, $t = timeout( 10 )
or die "expect returned $?" ;

warn "Starting first write\n";

print Writer qq~
exp_internal 1;
set timout 30\;
spawn telnet system

sleep 2

puts "NEXT"
~;

while (<Reader>) { last if /NEXT/; warn "READ\n"; print; }

warn "1\n";

It never gets past the while loop and it never puts out the READ warn
or any data either. I have tried moving this to use readline() in
both scalar and list context with the same results. Is there ANY way
to figure out why this is happening or to get data come back? I had
luck with IPC::Open2 but obviously I can't use that anymore under
mod_perl.

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1449
by: Swaroop C H | last post by:
Is there a Python equivalent of Perl's IPC::Run module http://search.cpan.org/dist/IPC-Run/lib/IPC/Run.pm ] ? Thanks! -- Swaroop C H Blog: http://www.swaroopch.info Book: http://www.byteofpython.info
0
1586
by: piyush | last post by:
Sorry for repeated posting but I couldnt get things right/completely in the first post. I am in the process of deciding the IPC mechanisms to use for communication between 1) An application API (which would be set up as a NT service). It could be C++ or C#. The API as such might be talking to the underlying application (UA) via WM_COPYDATA messages.
0
1806
by: piyush | last post by:
Sorry for repeated posts, I couldnt get things right and complete in the previous post. I am in the process of deciding the IPC mechanisms to use for communication between 1) An application API (which would be set up as a NT service). It could be C++ or C#. The API as such might be talking to the underlying application (UA) via WM_COPYDATA messages.
2
2812
by: J | last post by:
Hello, What is the best/easiest way to setup interprocess communication between a windows service and a webservice? The windows service will be running on the same machine that is hosting the web service. The web service will be calling the windows service to get information relating to the printers installed on this machine. J
2
6659
by: a_agaga | last post by:
Do you know are there some reasons why many do not make processes to communicate through memory? Why network connections (sockets) are used so commonly in IPC (inter process communication) instead of memory? (Is IPC harder to maintain / handle if it is made through memory, when compared to communication through sockets?) Some background things:
2
3775
by: Oriane | last post by:
Hi there, What is the "best" way to make to process communicate on the same machine, with .NET 2.0/3.0! - remoting on IPC ? Have you experienced this ? - WCF on IPC ? - any alternatives ? Thanks
2
2534
by: fahad.usman | last post by:
I am making an application in which if the second instance of the same application is launched, it checks its command-line arguments and passes them to the already running instance. I have been told by someone that using named pipes is one of the most commonly used ways of doing this. But I did it in a simpler way; I saved the command-line arguments in a text file and passed a message to the previously running instance to read the...
7
2671
by: Alex Y Wang | last post by:
Hi all, my current project is completely written in native C++, and for some reason I need to write a standalone .Net program to do some work for it. Therefore, I need to find an effective way of IPC between my unmanaged code and managed code. What's most appropriate IPC solution for this? Thanks in advance. Alex Y Wang
7
5474
by: adrin | last post by:
Hello, Could anybody tell me what are IPC mechanisms that .NET supports at present?(and what improvements were made in different framework versions)? Is IPC support windows dependent or is it designed to be more or less portable(does Mono support IPC?) tia --
0
7929
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8419
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8065
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8274
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5882
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3954
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.