neha_perl_help has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I found out that since I am trying to run scripts on windows, I cant use Expect. Can anyone please explain the EOT concept. I tried running it but the program is no compiling. Thanks for your help!

Replies are listed 'Best First'.
Re: Passing password with command
by Joost (Canon) on Sep 14, 2007 at 21:56 UTC
    if your program really reads from STDIN (update: instead of reading the terminal input directly - some unix programs read from /dev/tty for sensitive information, for example) and the command name really starts with a dash and you wouldn't try to redirect the output, it might work.

    Try this:

    my $pwd1 = "pwd1"; my $pwd2 = "pwd2"; open(FOO, "|$command") or die "open command failed: $!"; print FOO "$pwd1\n$pwd2\n"; close FOO;
    update 2: redirecting the output shouldn't have any serious consequences, but it may help in that it may show error messages that otherwise might get redirected

Re: Passing password with command
by runrig (Abbot) on Sep 14, 2007 at 21:23 UTC
    Maybe the command doesn't accept input through stdin. If this is a unix-ish system and something like this the following doesn't work from the command line, then look into Expect or the command line expect:
    command <<EOT pwd1 pwd2 EOT
    Updated wording.

    Update: Original post has been updated so this and any other answers no longer make any sense. Bad OP. Bad, bad OP. BTW, The 'EOT' thing is a "here doc" and is generally a unix concept (though there is the same sort of thing from within perl).

      Using a here document means that the input is being read from STDIN, which isn't what is needed.
        Maybe what I wrote is confusing...I said (or tried to say) to try a here document, and if it doesn't work, then the command does not read from STDIN, and then go look into expect.