Skogen
Skogen

Reputation: 721

How to pass arguments in php exec()?

I am trying to run a .exe application with input file and argument.

With cmd I can successfully start the executable like this...

C:\Program Files\MyApp.exe "path\to\input file" argument

However, nothing happens when I simply copy paste the string above into the exec() function like this..

exec("C:\Program Files\MyApp.exe "path\to\input file" argument") 

Do I need to escape parts of the string? How should I proceed?

Upvotes: 2

Views: 6244

Answers (2)

Frantisek Hallo
Frantisek Hallo

Reputation: 1711

I had to use this format

php -q "./yii.php" migrate/up --interactive=0 --migrationPath=@vendor/pheme/yii2-settings/migrations

Upvotes: 0

Carlos
Carlos

Reputation: 238

Just pass the arguments like a normal calling from shell

ex:

exec("C:\Program Files\MyApp.exe \"path to\input file\" argument") 

Upvotes: 3

Related Questions