in reply to Re: passing in User Input
in thread passing in User Input

Isn't there a way to use open to do this? This does not work but it gets close... What am I missing?
my $cmd=qq|runas /profile /user:$user "$exe"|; open(FH,"| $cmd") || die $^E; print FH "$pass\r\n"; close(FH);
http://www.basgetti.com

Replies are listed 'Best First'.
Re^3: passing in User Input
by monarch (Priest) on Jun 12, 2005 at 02:13 UTC
    I don't know the answer to your question. But there are a few things I would check if I had your problem.

    First: do you need to delay before passing the password (as suggested above)? ie. after opening your process put your process to sleep(5); to give your subprogram time to start up and ask the password question?

    Secondly: some programs, like passwd on linux, use tricks to ensure you can't just pass input via STDIN - this is to prevent nasty hacks that bypass security. To get around this a language called TCL/Expect is commonly used for applications that need to call passwd (the trick used is to log in again and execute the program through a login shell). That is why I suggested a Perl-equivalent, Expect. It is possible that the program you're using needs special handling like the linux passwd program.