4

After installing the necessary modules, the following command

azure account -help 

works as expected. However, when I invoke the same command from inside PHP using exec().

exec('azure account -help',$output,$responseCode)

and print the output, I get

$output: [] (empty array) and $responseCode: 8

I've tried executing the module using the command 'node'. Ex

node /usr/lib/node_modules/azure-cli/bin/azure.js account -help

This also works on command line but not through PHP's exec.

Edit: Redirecting the stderr with the following command:

exec('azure account -help &2>1',$output,$responseCode)

gives these details:

,E === undefined) && (process.env.HOMEDRIVE === undefined))) {throw new Error(, ^,Error: HOME not found, unable to store Streamline callback cache, at Object. (/usr/local/lib/node_modules/azure-cli/node_modules/streamline/lib/compiler/compile.js:278:90), at Module._compile (module.js:456:26), at Object.Module._extensions..js (module.js:474:10), at Module.load (module.js:356:32), at Function.Module._load (module.js:312:12), at Module.require (module.js:364:17), at require (module.js:380:17), at Object. (/usr/local/lib/node_modules/azure-cli/node_modules/streamline/lib/compiler/register.js:28:15), at Module._compile (module.js:456:26), at Object.Module._extensions..js (module.js:474:10)

What can I try to debug this further?

1
  • 1
    php is not bash and won't search azure command in PATH. Try calling it, using full path to azure. Commented Aug 27, 2013 at 10:37

2 Answers 2

3

The problem was solved by invoking exec() and providing a HOME env variable:

exec('HOME=/tmp/ azure account -help 2>&1');

Sign up to request clarification or add additional context in comments.

Comments

0

php do not know about node , so make sure you specify full path of nodejs something like

exec('c:/nodejs/node.exe mynode_scripts.js',$retr_err,$retr_val);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.