Exec()函数没有按我的意愿执行(OSX) [英] Exec() function not doing as I want (OSX)

查看:58
本文介绍了Exec()函数没有按我的意愿执行(OSX)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Howdy,


最近我从Windows PC切换到Mac OS-X 10.5(php v5.2.6)和

我有一点问题我的cd-management脚本中有一个函数。


为了从我的cd中提取一些信息,我有一个可执行文件,我用
执行exec():


$ discOutput = exec(''。/ discid / dev / rdisk2'');


可执行文件在与php脚本所在的目录相同。当我在同一目录中从终端运行同一行时,它给了我

我想要的输出,php没有'''根本不给我任何输出。


在''ls'这样的基本函数上输出exec()确实会返回一个

值,所以该功能有效。我想不知怎的,我没有正确地指向discid可执行文件,但我没有看到错误。


有人可以告诉我我的意思吗我做错了吗?


先谢谢,Maarten

Howdy,

Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.

For extracting a bit of info from my cd''s I have an executable which I
execute with exec():

$discOutput = exec(''./discid /dev/rdisk2'');

The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn''t give me any ouput at all.

Asking exec() for output on a basic function like ''ls'' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don''t see what is wrong.

Can someone tell me what I am doing wrong?

Thanks in advance, Maarten

推荐答案

discOutput = exec(''./ discid / dev / rdisk2'');


可执行文件与php脚本所在的目录位于同一目录中。当我从
运行同一行时它在同一目录下的终端给了我

我想要的输出,php根本不给我任何输出。


要求exec()为像''ls'这样的基本函数输出确实会返回一个

值,因此该函数处于活动状态。我想不知怎的,我没有正确地指向discid可执行文件,但我没有看到错误。


有人可以告诉我我的意思吗我做错了吗?


先谢谢,Maarten
discOutput = exec(''./discid /dev/rdisk2'');

The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn''t give me any ouput at all.

Asking exec() for output on a basic function like ''ls'' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don''t see what is wrong.

Can someone tell me what I am doing wrong?

Thanks in advance, Maarten


Maarten写道:
Maarten wrote:

你好,

最近我从Windows PC切换到Mac OS-X 10.5(php v5.2.6)和

我有一个我的cd-management脚本中有一个函数没什么问题。


为了从我的cd中提取一些信息,我有一个可执行文件我

执行exec():

Howdy,

Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and
I have a little problem with one function within my cd-management script.

For extracting a bit of info from my cd''s I have an executable which I
execute with exec():


discOutput = exec(''。/ discid / dev / rdisk2'');


可执行文件与php脚本所在的目录位于同一目录中。当我在同一目录中从终端运行同一行时,它给了我

输出我想要,php根本不给我任何输出。


要求exec()为像''ls'这样的基本函数输出确实会返回一个

值,因此该函数处于活动状态。我想不知怎的,我没有正确地指向discid可执行文件,但我没有看到错误。


有人可以告诉我我的意思吗我做错了吗?


在此先感谢,Maarten
discOutput = exec(''./discid /dev/rdisk2'');

The executable is in the same directory as the php script is in. When I
run the same line from Terminal within that same directory it gives me
the output I want, php doesn''t give me any ouput at all.

Asking exec() for output on a basic function like ''ls'' does return a
value, so the function is active. I guess somehow I am not pointing to
the discid executable correctly, but I don''t see what is wrong.

Can someone tell me what I am doing wrong?

Thanks in advance, Maarten



我确实无法肯定但我刚刚切换从Windows到Linux

并且在执行脚本时遇到了类似的问题...


尝试将包含文件夹添加到系统路径和/或使用

绝对路径而不是./&;无论如何,这解决了我的问题。


祝你好运:-)


Roger。

Well I cant say for sure but I''ve just switched from Windows to Linux
and had been having some similar problems execing scripts...

Try adding the containing folder to your system path and/or using
absolute path instead of "./" That fixed my problems anyway.

Good luck :-)

Roger.


这篇关于Exec()函数没有按我的意愿执行(OSX)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆