Hi All,
I am stuck because I have to run a tool using a perl script and it asks for user name and reason for running it.But I am not able to pass these arguments to my script.I have used IPC (Open2 and pipes).Please suggest me how to accomplish this.This is how my tool runs from command prompt -
root@c001n03 ICtool# perl IC4.pl --full
User name : abhinav
Reason for running IC tool: testing

Here is my rough part of code through which I am trying to run this tool -
use IPC::Open2; my $pidSsh = open2($RDR,$WTR,"perl /mnt/1/service/ICtool/IC4.pl --full +"); print "Just for debugging :third line\n"; my $line1 = <$RDR>; print $line1; print $WTR "Abhinav \n" if ($line1 eq "User name :"); my $line2 = <$RDR>; print $line2; print $WTR "Testing \n" if ($line2 eq "Reason for running IC tool:");
The script is going to the third line where it is printing "Just for debugging :third line".But it is not asking for the User name and reason.So the tool is not getting executed using this script.Please suggest me how do I proceed.
I tried to implement the suggestions of the revered monks.Even if I dont read anything from the read handle (just write the user name and reason to the write handle) even then program does not run.So problem cant be solved with changing input record separator.I am using PERL Version 5.8.3 which does not have Expect.pm .What else can I do with the current version for the script to run?

In reply to Cannot read from STDIN and write to STDOUT using IPC and pipes by abhinav

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.