Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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

by kcott (Bishop)
on Oct 18, 2013 at 07:17 UTC ( #1058712=note: print w/replies, xml ) Need Help??

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

G'day andyarp,

Welcome to the monastery.

I'm unfamiliar with manage-bde. When you said "It then pops up asking ...", I thought it sounded like a GUI; however, in the next sentence, you write "... automatically type them into the prompt ...", which sounds less like a GUI, and more like 'enter a value when prompted'. Some clarification on this would help.

There's potentially a few ways you could do this. Here's some examples:

-- Ken

Replies are listed 'Best First'.
Re^2: Use a perl variable on a command that prompts for input
by hippo (Chancellor) on Oct 18, 2013 at 08:38 UTC

    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.

      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

      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?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2019-10-14 18:12 GMT
Find Nodes?
    Voting Booth?