2

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

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

exec('./print.out')

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

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

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

1
  • Any output from ./argument.out -n 1234 execution ? Commented May 2, 2010 at 18:56

1 Answer 1

4

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

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).

Sign up to request clarification or add additional context in comments.

2 Comments

So if I'd like to pass 2 arguments I should do exec("./argument.out '-n 1234 -o 5678'") or exec("./argument.out '-n 1234' '-o 5678'") ?
when i m trying to run exec("./a.out '-n 1234'") i m getting error:bash: syntax error near unexpected token `"./a.out '-n 1234'"'

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.