perl, how to make a system call and pass parameter

Posted on 2011-10-10
Last Modified: 2012-05-12
$exitval = system "scripts/";   #this works
$exitval = system "scripts/ $MYDIR";  #this does not work

It has to be a system call and not backticks.  So how do I send parameter?
Question by:rgbcof
    LVL 84

    Expert Comment

    What did you try, and what were the results that lead to the conclusion that it does not work?
    LVL 7

    Accepted Solution

    It should be:


    So, this should work:

    $exitval = system("scripts/", "$MYDIR");
    LVL 84

    Assisted Solution


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

    LVL 9

    Expert Comment

    What are $? and $! values after the system() failure?

    Author Closing Comment

    Works great.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
    In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
    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…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    731 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now