想用exec()函数从php运行c程序

时间:2022-11-07 01:25:17

i'm trying to run one c executable file using php exec().

我正在尝试使用php exec()运行一个c可执行文件。

When c contains a simple program like print hello. I'm using

当c包含一个简单的程序,如打印你好。我在用着

exec('./print.out')

It's working fine. But when I need to pass a argument to my c program I'm using

它工作正常。但是当我需要将参数传递给我正在使用的c程序时

exec('./arugment.out -n 1234')

It is not working. Can any body tell me how to pass arugment using exec to c program.

它不起作用。任何人都可以告诉我如何使用exec将程序传递给c程序。

1 个解决方案

#1


4  

From taking a look at the php documentation, it appears that exec treats arguments a bit oddly. You could try doing

从看看php文档看来,exec看起来有点奇怪。你可以试试

exec("./argument.out '-n 1234'")

to prevent it from mangling them (it normally separates them all on space, which might be what's messing it up).

防止它被破坏(它通常将它们全部分隔在空间上,这可能会使它变得混乱)。

#1


4  

From taking a look at the php documentation, it appears that exec treats arguments a bit oddly. You could try doing

从看看php文档看来,exec看起来有点奇怪。你可以试试

exec("./argument.out '-n 1234'")

to prevent it from mangling them (it normally separates them all on space, which might be what's messing it up).

防止它被破坏(它通常将它们全部分隔在空间上,这可能会使它变得混乱)。