Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Use a perl variable on a command that prompts for input

by hippo (Curate)
on Oct 18, 2013 at 08:38 UTC ( #1058725=note: print w/ replies, xml ) Need Help??


in reply to Re: Use a perl variable on a command that prompts for input
in thread Use a perl variable on a command that prompts for input

In addition to Ken's three options here, there is also the possibility of using echo inside the system command as in:

system ("echo my_input | some_command arg arg arg");

The advantages I find in this are that it is simple and can easily be tested in the shell before embedding it in your Perl script.

The downside is mostly a lack of portability but also perhaps consideration of properly escaping my_input to cope with the possible shell expansions.


Comment on Re^2: Use a perl variable on a command that prompts for input
Download Code
Re^3: Use a perl variable on a command that prompts for input
by andyarp (Initiate) on Oct 23, 2013 at 00:23 UTC

    I'm looking into all these options. Yes it is a message that comes up in the command prompt area. I'm going to give this echo command a try. It sounds like it may work

Re^3: Use a perl variable on a command that prompts for input
by andyarp (Initiate) on Oct 23, 2013 at 00:38 UTC

    I tried the "Echo" option, but i kept getting "the handle is invalid", so i think it may be a no-go.

      Did you test it in the shell before embedding it in your perl script as suggested? If so, did it work there?

      If you can pipe input at the shell prompt you can almost certainly do so in the perl script. Otherwise you'll probably have to resort to Expect or similar. Good luck.

      I did try it in the regular console and it returned with

      an error occured (code 0x80070006): The handle is invalid.

      The problem with this is it prompts for the pin, and then prompts to confirm.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058725]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2014-09-20 23:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (163 votes), past polls