maya75 Posted August 23, 2006 Share Posted August 23, 2006 Hello,When I do this in a Linux command line :[CODE]perl -e 'system("php myscript.php a b")'[/CODE]it works, i.e. I have a string as the return value.But If I do this inside my perl script :[CODE]$var = system("php myscript.php a b");[/CODE]it doesn't works, i.e. I have 0 as the return value ($var).The code of script.php is :[CODE]#!/usr/bin/php -q<?phpecho $argv[1].$argv[2];?>[/CODE]Can you see the problem ? Thanks a lot for any help :) Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 23, 2006 Share Posted August 23, 2006 Unfortunately the system() command only returns the status result of the command argument. Therefore if it executes properly a 0 will be returned. That's why your var is set to 0. The only way to get the output of a command is to use the pipe command and have the output redirected to a file handler... like so:[code]open (HTML_FILE, "php myscript.php a b |");[/code] Quote Link to comment Share on other sites More sharing options...
maya75 Posted August 23, 2006 Author Share Posted August 23, 2006 Wow, thanks for your quick and appropriate answer :o :DI'm going to have a look at the pipe command + file handler proposition you gave.Kind Regards. Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 23, 2006 Share Posted August 23, 2006 no problem... glad to help Quote Link to comment Share on other sites More sharing options...
maya75 Posted August 24, 2006 Author Share Posted August 24, 2006 Hi again,I found an alternative method which works fine ;D :[code]$var = `php myscript.php a b`;[/code]Bye! Thanks again. Quote Link to comment Share on other sites More sharing options...
Corona4456 Posted August 24, 2006 Share Posted August 24, 2006 ah... nice :)... thanks for the info Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.