On 7/5/07, Lakshmi Sailaja <[EMAIL PROTECTED]> wrote:

I want to automate the following through Perl:
su - user
and provide password
check if the login is successful or not.

You'll probably have an easier time using sudo, instead of su; it's
made for this sort of thing. See whether yours has the -S command line
option, to get the password from its standard input instead of the
terminal. You could try using IPC::Open3, maybe something like this:

 my($wr, $rd, $er);
 my $pid = open3($wr, $rd, $er, 'sudo -S some command');
 sleep 1; # let it start and ask for password
 print $wr "seCret\n";  # the password

Good luck with it!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to