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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

why simple perl output is different form expected ?

Hi,

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 :

/usr/local/lib/php.ini

Appreciates any assistant in this issue.

Thanks.
0
smksa
Asked:
smksa
1 Solution
 
ozoCommented:
Unless you had set the value of $5 to something relevant, you probably want
$phpcmd ="php -i|grep lib/php.ini|awk '{ print \$5 }'";
or
$phpcmd =q"php -i|grep lib/php.ini|awk '{ print $5 }'";
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now