Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: redirecting stdin on windows

by myocom (Deacon)
on Aug 20, 2002 at 22:14 UTC ( [id://191608]=note: print w/replies, xml ) Need Help??


in reply to redirecting stdin on windows

What you're asking to do doesn't require Perl at all - the shell can already do it. Create a text file with the username on one line and the password on the next <insert speech about how you shouldn't store passwords in plaintext>. Then, you can simply do myexe.exe < answer.txt where answer.txt is the "answer file" you created.

If you really wanted to get Perl involved for some other reason, you could do this same thing from a call to system.

"One word of warning: if you meet a bunch of Perl programmers on the bus or something, don't look them in the eye. They've been known to try to convert the young into Perl monks." - Frank Willison

Replies are listed 'Best First'.
Re: Re: redirecting stdin on windows
by arkamedis21 (Acolyte) on Aug 21, 2002 at 13:55 UTC
    I tried doing

    command < input_file

    but it only works if the command asks for one input entry, in windows.

      Funny, it works for the following (on WinXP):

      script.pl
      print "username: "; chomp ($uname = <STDIN>); print "\npassword: "; chomp ($password = <STDIN>); print "\nYou entered username $uname and password $password\n";
      answer.txt
      someusername somepassword
      And I'm calling it like this:
      perl script.pl < answer.txt
      ...which produces this:
      C:\test\scratch>perl script.pl < answer.txt username: password: You entered username someusername and password somepassword
      ...which is the expected output.
      "One word of warning: if you meet a bunch of Perl programmers on the bus or something, don't look them in the eye. They've been known to try to convert the young into Perl monks." - Frank Willison

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-18 03:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found