Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: How to call a script interactively from perl

by LetMeAsk (Initiate)
on Oct 16, 2012 at 14:34 UTC ( #999345=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to call a script interactively from perl
in thread How to call a script interactively from perl

I am sorry to confuse you, ok here i go again: There is an existing script (Lets call it ThirdPartyScript and i cannot do any modifications to it) which performs some processing and displays output on the STDOUT and at the end it asks for options. For example, when you provide an option "i" it means include flag and you can specify any search string. It then retrieves the results matching that search string from its database and after displaying those results it again wait for next action with the following prompt:
Select option:
Now, either you can provide next option as i (to include other search string or "d" to delete the listed results etc or "X" to quit script. Now, i am writing a perl script with the intention to run above thirdpartyscript with a specific search string from this perl code and write the result of this run to a unix file. Then again my perl code will email this output file to the interested parties. My perl code works fine when i run that for any other command (e.g. ls), but when i run that for the above third party script, it never completes execution and the output file never populated. So, i thought may be it is because the thirdpartyscript do not exit execution until an "x" is specified as explained above. Please let me know if it helps. Thanks

Replies are listed 'Best First'.
Re^5: How to call a script interactively from perl
by McA (Priest) on Oct 16, 2012 at 14:44 UTC

    Hi!

    This sounds to me like your ThirdPartyScript handles the input from a console/terminal which is a little bit differnet than reading from STDIN. If this is the case then have a look at Expect.pm.

    Best regards
    McA

      Thanks i read about Expect.pm and looks like it can help but do you think there is nay other solution to this (within Perl)? as i do not have Expect.pm installed on my production systems.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999345]
help
Chatterbox?
[james28909]: it is not an absolute date like "27" or "31". sometimes it is like wednesday or friday
[james28909]: and i need to format those special instances into an absolute date instead of "yesterday"
[stevieb]: ask a question on SoPW, and include at least a half-dozen examples of the input, and at least one example of expected output
[davido]: Exactly: SoPW. This isn't going to be solved easily in the CB.
[james28909]: in need "yesterday" and so on, to be absolute like "1" or "31"
[stevieb]: ...and throw some of your existing code into the equation as well, just so readers know you've given a try at it ;)
[james28909]: ok
[stevieb]: davido thanks for the link ;) I was being the typical lazy
[davido]: date parsing is hard. The more examples you can provide of the input (within reason) and expected output, the better.
[stevieb]: agreed. That's why I said at least a half-dozen. If enough of the different formats are present, the date/time folk may not have to request more. If they do, then at least there was a decent base to start with

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2017-04-29 02:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.