Hi all!
I'm having a slight problem using the system() function in ActivePerl (I'm using ActivePerl 5.8)
Example: system("app.exe","parameter1","parameter2");
This works fine executing app.exe with parameter1 & parameter2. The problem I have is that app.exe requires additional user input in form of a password to run the requested action. I would like my perl script to supply this password as well as the parameters, not prompting the user for the password.
Is this possible? How do I go about doing this?
Thanks in advance for any help!
Regards, Magnus
I don't know if you can send that parameter to the proggy from perl if it's process replaces the one your in during the system call.
Here's a script to pass the password to system ssh2 call. It uses win32 guitest. Maybe this will give you an idea. I haven't tested it much, but it seems to do the trick.
-- mike higgins
use IPC::Open2; use Win32::GuiTest qw(FindWindowLike GetWindowText SetForegroundWindow SendKeys);
$Win32::GuiTest::debug = 0;
my %config = ( user=>'usr', password=>'pswd', host=>'host.com', );
my @cmds = ( 'ls -l', 'cd /home/scsi*;ls -1');
foreach my $cmd (@cmds){
my $result = command ($cmd,\%config);
print $$result;
}sub command {
my ($cmd, $config) = @_;
my $regex = qr/\Q$0\E/;
my $result;
my $pid = open2( \*READER, \*WRITER, 'ssh2',
"$config->[EMAIL PROTECTED]>{host}",
"$cmd") || die "ssh: $!";sleep 2;
my @windows = FindWindowLike(0, "");
my $window; for (@windows) {
my $window_title = GetWindowText($_);
if ( $window_title =~ m/$regex/ ){
$window = $_;
last;
}
}SetForegroundWindow($window);
SendKeys("$config->{password}~");
while (<READER>) { chomp(); $result .= $_ . "\n"; }
close(READER);
close(WRITER); return \$result;
}_______________________________________________ ActivePerl mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
