0

I am trying to use exec(), system(), passthru() or anything to read in the output of iscsiadm -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 empty scsi_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?
Fabio
  • 18,856
  • 9
  • 82
  • 114
c card
  • 213
  • 3
  • 10
  • Check that iscsiadm isn't writing to stderr. Repeat your terminal command line with `2>&1` at the end, which redirects stderr to stdout, and will then send that output to your scsi_sess file. – Marc B Sep 21 '11 at 14:59
  • Maybe the output is sent to stderr. Try `iscsiadm -m session 2>&1` to redirect stderr to stdout. – Sjoerd Sep 21 '11 at 14:59

1 Answers1

0

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

Fabio
  • 18,856
  • 9
  • 82
  • 114