At 5:46 PM -0400 5/7/04, Sherm Pendley wrote:
On May 7, 2004, at 3:29 PM, Chuck Rice wrote:

How do I set up a perl program such as the one below to check mail without hard coding the password in the code?

If you're using Panther, the "security" command-line tool looks like it might be useful. You can use it to access the keychain from a script. "man security" for more info.


You'll need to open it as a child task using both input and output; for more about doing that from Perl, see "perldoc IPC::Open2" and perldoc IPC::Open3".

sherm--

Not sure about the child task stuff, but this code seems to get the password from the keychain, (assuming that you have a keychain entry called emailpassword). Pretty cryptic, and I am sure beginnerish, but it works. -Chuck-


#!/usr/bin/perl my $temp;
my $pass;
$temp = `security find-internet-password -a emailpassword -g 2>&1`;
$temp =~ /password: "([A-Za-z]*)"/;
$pass = $1;
print "$pass";



-- Fight Spam! Join CAUCE! == http://www.cauce.org/

Reply via email to