Can parameters be passed to an app with exec()

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
breezue89
New php-forum User
New php-forum User
Posts: 3
Joined: Thu Mar 16, 2017 3:16 pm

Fri May 11, 2018 1:43 pm

Hey guys
I’m trying to run an app via php but I can’t find a way to pass the parameters required to make it work because they contain multiple double quotes.
I can start the app and display the output with this code:

Code: Select all

<?php

$myCmd = 'c:\\xampp\\htdocs\\tuo\\tuo.exe ';
$result = exec($myCmd,$output);
var_dump($output);
But to execute any kind of command requires a string like this:
tuo "Cyrus, Medic, Revolver, Imperial APC, Medic, Imperial APC" "Mission #94" pvp random fund 0 climb 10000 dom-owned
is it possible to pass that string as a parameter with exec()? if not, is there another way to get what I want?

chorn
php-forum Fan User
php-forum Fan User
Posts: 560
Joined: Fri Apr 01, 2016 2:18 am

Sat May 12, 2018 12:33 am

just use the same command you would on a commandline. You only need to escape the slashes and the quotes according to your quoting style.

breezue89
New php-forum User
New php-forum User
Posts: 3
Joined: Thu Mar 16, 2017 3:16 pm

Sat May 12, 2018 7:54 pm

Cracked it, thanks!

Post Reply