why simple perl output is different form expected ?

Posted on 2009-12-30
Last Modified: 2013-12-26

May i know why my perl script is producing output differently ?

$phpcmd ="php -i|grep lib/php.ini|awk '{ print $5 }'";
$phpini = `$phpcmd`;
print "$phpini";

The output will be :

Loaded Configuration File => /usr/local/lib/php.ini

where the command "php -i|grep lib/php.ini|awk '{ print $5 }'" if run manually in shell/bash will produce just :


Appreciates any assistant in this issue.

Question by:smksa
    1 Comment
    LVL 84

    Accepted Solution

    Unless you had set the value of $5 to something relevant, you probably want
    $phpcmd ="php -i|grep lib/php.ini|awk '{ print \$5 }'";
    $phpcmd =q"php -i|grep lib/php.ini|awk '{ print $5 }'";

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    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…

    745 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

    19 Experts available now in Live!

    Get 1:1 Help Now