Jason Tang
Jason Tang

Reputation: 31

PHP exec("phonegap -v") didn't work

This is PHP my code:

exec('phonegap -v 2>&1',$output, $retval);
echo 'Return value: ' . $retval;
print_r($output)

return:

Return value: 1Array ( [0] => path.js:8 [1] => throw new TypeError('Path must be a string. Received ' + [2] => ^ [3] => [4] => TypeError: Path must be a string. Received undefined [5] => at assertPath (path.js:8:11) [6] => at Object.posix.join (path.js:479:5) [7] => at Object. (/home/phonegap/node-v4.4.5-linux-x64/lib/node_modules/phonegap/node_modules/phonegap-build/lib/common/config/global.js:17:28) [8] => at Module._compile (module.js:409:26) [9] => at Object.Module._extensions..js (module.js:416:10) [10] => at Module.load (module.js:343:32) [11] => at Function.Module._load (module.js:300:12) [12] => at Module.require (module.js:353:17) [13] => at require (internal/module.js:12:17) [14] => at Object. (/home/phonegap/node-v4.4.5-linux-x64/lib/node_modules/phonegap/node_modules/phonegap-build/lib/common/config.js:9:13) )

When I execute the command in the bash shell, it works. But in my PHP script, It won't. Any ideas, why?

Upvotes: 3

Views: 227

Answers (1)

pguetschow
pguetschow

Reputation: 5337

Either use the backtick operator (``) or shell_exec

Upvotes: 0

Related Questions