The backtick version would look something like:
my $cmd = "certutil -f -enterprise -addstore root $cert > NUL"; my $output = `$cmd 2>&1`; # output should contain STDOUT and STDERR my $returnCode = $?; # whatever value the external process returned Typically I wrap commands in either some sort of OO-ish package, or in a function to help hide the implementation details of external commands from the program. This makes it more portable, especially if someone has a wild hair and decides to call OS-specific utilities. ________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, March 27, 2007 1:00 PM To: [email protected] Subject: Questioning wisdom of system() call inside an eval block Perlers, I feel like I know just enough about this to be dangerous, so I'll put it to you. I'm beginning to suspect a chunk of code isn't doing what I need it to. I've looked through the perldoc on system(), and that's what really started me wondering. What I'm not sure about is which way to go to fix this--especially since it seems to work. Here's the code I'm looking at: eval { system( "certutil -f -enterprise -addstore root $cert > NUL 2>&1" ); }; $@ and Carp::croak( "Error installing certificate ($@)" ); where $cert contains the name of a certificate file (foo.cer). Is there an easier, or cleaner, way of running a program? How, and what, would I replace in this jumble using backticks--would that be a better way to go? Thanks to anyone who'll help me make sure I'm DWIM! Deane Rothenmaier Programmer/Analyst Walgreens Corp. 847-914-5150 "I am but mad north-north-west. When the wind is southerly I know a hawk from a hand-saw." -- Hamlet (Act II, scene ii)
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
