Front page | perl.beginners |
Postings from April 2003
RE: passing a password
Thread Previous
|
Thread Next
From:
Kipp, James
Date:
April 30, 2003 05:50
Subject:
RE: passing a password
Message ID:
EC6C49DE5C846143AA2CE580420E77C331DB06@xexwlm05.mbnainternational.com
>
> $queue is the printer i want to add. The problem is that the
> cupsaddsmb
> utility prompts for a password. How can I send that password along to
> the program? I tried making my system call with a pipe to an echo
> password like this:
>
> system("/usr/sbin/cupsaddsmb -U admin $queue | echo password");
>
> Any help would be greatly appreciated. Thanks.
>
Have you looked at the 'Expect' module? I am not sure it will work in this
case, but it has worked for me with programs like su and telnet. here is
some code from a script i did a while ago (although I can remember if I
actually got this to work :) :
use Expect;
.....
my $su = Expect->spawn('/bin/su',$user) or die "Can't start Program:
$!\n";
# stop the output from going to STDOUT
$su->log_stdout(0);
# capture pw and die with appropriate string if pw is wrong
my $error = ($su->expect(10, 'password:'))[1];
if ($error)
{
print $su "Sorry.\r";
$su->soft_close();
}
$su->soft_close();
exit 0;
Thread Previous
|
Thread Next