in reply to passing in User Input

I haven't used it personally, but Win32::CtrlGUI may very well help you out -- use system to kick off Runas (or whatever commandline program), and use Win32::CtrlGUI to find the resulting dos window by name, and send it the password (possibly after a sleep).

Replies are listed 'Best First'.
Re^2: passing in User Input
by slloyd (Hermit) on Jun 12, 2005 at 01:30 UTC
    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
      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.