[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

perl, how to make a system call and pass parameter

Posted on 2011-10-10
5
Medium Priority
?
337 Views
Last Modified: 2012-05-12
$exitval = system "scripts/myscript.pl";   #this works
$exitval = system "scripts/patch_fdcs.pl $MYDIR";  #this does not work

It has to be a system call and not backticks.  So how do I send parameter?
0
Comment
Question by:rgbcof
5 Comments
 
LVL 85

Expert Comment

by:ozo
ID: 36945977
What did you try, and what were the results that lead to the conclusion that it does not work?
0
 
LVL 7

Accepted Solution

by:
ziceva earned 1000 total points
ID: 36945997
It should be:

system("command","arg1","arg2");

So, this should work:

$exitval = system("scripts/patch_fdcs.pl", "$MYDIR");
0
 
LVL 85

Assisted Solution

by:ozo
ozo earned 1000 total points
ID: 36946019

$exitval = system "scripts/patch_fdcs.pl", $MYDIR;
would be preferable to
$exitval = system "scripts/patch_fdcs.pl $MYDIR";
if $MYDIR contains metacharacters that you don't want interpreted by the shell,
But they should otherwise be equivalent, and both can work.


0
 
LVL 9

Expert Comment

by:parparov
ID: 36946136
What are $? and $! values after the system() failure?
0
 

Author Closing Comment

by:rgbcof
ID: 36946810
Works great.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question