CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Perl denying shell argument

 



tadi18
Novice

Apr 14, 2009, 11:10 AM

Post #1 of 3 (330 views)
Perl denying shell argument Can't Post

I have the following snippet of code in perl and I am trying to use shell commands in it. I see an issue with passing shell arguments.

@files1 = `find /u01/temp/https-* -type f -name key.kdb`;
&list_files ;

sub list_files
{
foreach (@files1)
{
`sudo /usr/local/ibm/gsk7/bin/gsk7cmd -keydb -expiry -db $_ -pw dummy`;

}
}


When I ran the above script, I get the following error:

/u01/temp/https-agateST/certs/key.kdb
sh: line 2: -pw: command not found
/u01/temp/https-agents/certs/key.kdb
sh: line 2: -pw: command not found




When I removed the "-pw", it ran with no errors but it didn't print any output. How do I pass those arguments? I tested the same line on unix shell and it works fine. Pleas help!


1arryb
User

Apr 15, 2009, 8:19 AM

Post #2 of 3 (317 views)
Re: [tadi18] Perl denying shell argument [In reply to] Can't Post

Hi tadi18,

Look for an embedded space in one of the @files1 filenames. Try quoting $_ in the command:

Code
... 
foreach (@files1) {
# For security reasons, you should always capture the output of backtick commands.
my $ret = `sudo /usr/local/ibm/gsk7/bin/gsk7cmd -keydb -expiry -db \"$_\" -pw dummy`;
}


Cheers,

Larry


Tumata
User


Apr 16, 2009, 1:31 AM

Post #3 of 3 (311 views)
Re: [tadi18] Perl denying shell argument [In reply to] Can't Post

What output do you want to see? I don't see any commant that maeks output...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives