SA-MP Forums Archive
PHP and SSH - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Other (https://sampforum.blast.hk/forumdisplay.php?fid=7)
+--- Forum: Everything and Nothing (https://sampforum.blast.hk/forumdisplay.php?fid=23)
+--- Thread: PHP and SSH (/showthread.php?tid=588175)



PHP and SSH - DRIFT_HUNTER - 06.09.2015

Ok i have been banging my head for like half an hour just why my command is not working from PHP but it does from terminal.

Then i decided to switch from ' to " and it works! Now the question is why the fuck its working like these?
pawn Код:
//Does not work (No error, no return string, and it does not return false, and it does not start server)
$stream = ssh2_exec($connection, 'screen -dmS ', $username ,' ./samp03svr');

//Works (Returns empty result as it should)
$stream = ssh2_exec($connection, 'screen -dmS sampsrvuser ./samp03svr');

//Works in a strange way, it drops empty return and empty error, but it works (maybe something with how screen works)???
$stream = ssh2_exec($connection, "screen -dmS ". $username ." ./samp03svr");
Could anyone explain me why it doesn't work if i use single quotes and variable in a string but does with double quotes or if i dont use variable to format string?
Also $username is defined as: $username = 'sampsrvuser'; so i dont see any problem there...


Re: PHP and SSH - Potassium - 06.09.2015

Why is the last one concatenated but the first one isn't? I'm still new to this and learning as I go, but I'm assuming that your issue wasn't with ' and ", it was that your first one had commas instead of dots. It's reading it as separate parameters with the commas, whereas the last one only has two parameters because you've concatenated the string... I could be wrong.


Re: PHP and SSH - DRIFT_HUNTER - 06.09.2015

Quote:
Originally Posted by Potassium
Посмотреть сообщение
Why is the last one concatenated but the first one isn't? I'm still new to this and learning as I go, but I'm assuming that your issue wasn't with ' and ", it was that your first one had commas instead of dots. It's reading it as separate parameters with the commas, whereas the last one only has two parameters because you've concatenated the string... I could be wrong.
Yep thats it...Thank you very much! I was googling about these but always with a wrong question


Re: PHP and SSH - Potassium - 06.09.2015

Awesome, I'm glad you fixed it!