dsadasd12132 2011-09-21 14:55
浏览 63
已采纳

php获取iscsi输出linux

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?
  • 写回答

1条回答 默认 最新

  • douying2243 2011-09-21 14:59
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!