php get iscsi output linux

7

I am trying to use exec(), system(), passthru() or anything to read in the output ofiscsiadm -m session, am not having much luck, and a little lost.

What I (think i) know:

  • It is not a sudoers or permission problem, as the results are the same in a terminal or browser (and my sudoers is already successfully setup to use iscsiadm for login/out)
  • Executing the following command from a terminal,iscsiadm -m session > /tmp/scsi_sess yields an emptyscsi_sess file

What I need to know:

  • Where is the output getting sent, that I can not read it with a bash or php script but can see it in the terminal?
  • How can I read the output, or get output sent somewhere that I can read it?
812

Answer

Solution:

With your syntax you're catching only the stdout. You should redirect the stderr on the stdout with

iscsiadm -m session 2>&1 /tmp/scsi_sess

Remember, when you do a redirect with> file and you still see output, that output is from stderr and not from stdout

http://en.wikipedia.org/wiki/Standard_streams

People are also looking for solutions to the problem: Cannot call WCF service methods from php script

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.