Solved

Expect.pm, sending long commands

Posted on 2004-09-17
8
380 Views
Last Modified: 2008-01-09
I need to have my Perl script send up to 200 KB of text to an executing process's stdin, and only then await a response. I have been using Expect.pm, but it hangs when asked to send more than ~50KB of text. I've noticed that my shell (BASH on Cygwin on Windows XP) also won't let me append more than ~50KB of text to a program's stdin. Could this limitation be a function of Cygwin or Windows, rather than Expect.pm? How can I get around this?

Thank you.
0
Comment
Question by:bobwood2000
  • 4
  • 3
8 Comments
 
LVL 20

Expert Comment

by:jmcg
ID: 12119070
Expect is using ptty (pseudo teletype) interfaces. There are traditionally limits in how much input can be entered on one line when using canonical text entry on a tty. I don't see how this particular limit could cause the hang you describe.

One thing to try is to have your Perl script break up what it is sending to the program into chunks considerably smaller than 50KB and pause between sending chunks. If a "sleep(1);" is too long, you can try using one of the other mechanisms (such as 'select') for a shorter interval.

Adding a pause is not going to help if there is really a deadlock between consumer and producer. If the process you are feeding the 200KB to is doing something else that can cause it to be blocked besides simply reading its input (for instance, if it is connected with a pipe back to your process or is reporting progress back to the ptty while reading), you may need to modify what you are doing to drain the stream that is getting clogged.

I'm not sure what you meant by the BASH on Cygwin on Windows example. How are you appending text? From a file? From the script itself with a << ("here document") redirection?
0
 

Author Comment

by:bobwood2000
ID: 12129554
Thanks for the feedback. I'll try breaking up the input into smaller chunks and let you know whether that works.

By "BASH on Cygwin on Windows" I meant that my operating system is Windows and BASH is my shell. I'm using Cygwin to provide a Unix-like environment while I'm running Windows, such that Expect.pm will work. Otherwise, Expect.pm doesn't support Windows.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 12129695
OK, I'll be interested to hear what you find out. I've not used Cygwin much, but it's hard to believe there'd be a limitation on the total amount you can pass to a program. The 50KB is approaching the 64KB that can be described by a 16-bit integer, so perhaps there's a limitation on individual buffers that can be attributed to a 16-bit legacy in the implementation.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 20

Expert Comment

by:jmcg
ID: 12194986
Anything to report?

I've been pulled in other directions than paying attention to Experts Exchange this month. I'm still interested in finding out what the problem was and whether I can offer any more help.
0
 

Accepted Solution

by:
bobwood2000 earned 0 total points
ID: 12196334
Yeah, breaking into chuncks didn't seem to do it. My "solution" has been just to not process data that is > 50 KB. This actually works well enough for my current project.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 12199922
Shall we close this question (I think it might be worth keeping in the database) and refund your points, since we didn't get you a resolution?
0
 

Author Comment

by:bobwood2000
ID: 12206173
Yes, sounds good. Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
read PayflowPro reports using the report metadata using perl 11 36
Rename file based on contents in the file? 3 80
syslog unix file 20 68
perl: Cleaning meta tags using RegEX 12 60
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now