Let's first off all bring this down to earth a little bit. The following line:
exec("C:\\xampp\\upload.exe backup /command \"option confirm off\" \"put C:\\big boy\\Documents\\dev notes\\\" \"exit\"");
You're mainly interested in the actual string of the command, let's rewiew it:
C:\xampp\upload.exe backup /command "option confirm off" ⤦
⤥"put C:\big boy\Documents\dev notes\" "exit"
As it should now be obviously visible to you, this is not a valid command in shell. Consult the documentation of upload.exe
in which format the value of the /command
switch has to be passed.
As you have not provided any reference what upload.exe
is, I can not give a more concrete suggestion here. However, one common way to deal with these problems is to first assign the command to a variable and then execute it. This allows to display debugging information which then allows to easily fix things:
$command = "C:\\xampp\\upload.exe backup /command \"option confirm off\" \"put C:\\big boy\\Documents\\dev notes\\\" \"exit\"";
exec($command);
It might be that it's just (guessed only, this is how it work with cmd /k
):
$command = 'C:\xampp\upload.exe backup /command ""option confirm off" ⤦
⤥"put "c:\big boy\Documents\dev notes\" "exit""';
Edit: And now as you wrote it is actually the winscp.com
command, I would assume:
$command = 'C:\xampp\upload.exe backup /command "option confirm off" ⤦
⤥"put ""c:\big boy\Documents\dev notes\""" "exit"';
With the following rules:
Each single command has to be wrapped into "
quotes if it contains spaces.
option confirm off
"option confirm off"
If a command contains also "
quotes, those have to be doubled ""
put "c:\big boy\Documents\dev notes\"
"put ""c:\big boy\Documents\dev notes\"""