On May 11, 2004, at 3:35 PM, Chuck Rice wrote:
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";
--
I would think that you can have digits in your password. I would change it to be
$temp =~ /password: "([A-Za-z0-9]"/;
Joe.
------------------------------------------------------------------------ --------------
Joseph Alotta, Principal (630) 969-2628
Open Door Investment Advisors, Inc. www.opendoorinvestments.com
409 North Washington Street certifiedfinancialplanner_at_earthlink_dot_net
Westmont, IL 60559 USA qualified, professional, friendly
------------------------------------------------------------------------ --------------