in reply to how to send input to stdin automatically?

Many programs that read passwords do not read them from STDIN - they read keystrokes from the terminal. If CVS is one of those, then sending data to its STDIN will not help you.

But yes, you can run a program from Perl and pipe data to its STDIN...

open my $pipe, '|-', 'some-program arg1 arg2'; print {$pipe} "some data\n"; close $pipe;

If you also need to read from that program's STDOUT or STDERR, check out IPC::Open2, IPC::Open3 or System::Command.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^2: how to send input to stdin automatically?
by salva (Canon) on Dec 18, 2012 at 09:06 UTC
    ssh (as most programs asking for a password) does not read the password from stdin but from the process tty, so not opening a pipe neither using any of the modules you have named will work.

    The usual solution to automate password authentication is to use Expect.

Re^2: how to send input to stdin automatically?
by skyworld_chen (Acolyte) on Dec 18, 2012 at 08:37 UTC
    Hi tobyink,

    thanks for your kind reply. You are right, I do need to send password to keyboard, not STDIN. I have tried code you suggested, but the linux still asks for the password. My code is as this:

    #!/usr/bin/perl open my $pipe,'|-', 'cvs update'; print {$pipe} "my_password\n"; close $pipe;

    did I miss something? thanks.