PHP and SSH
#1

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...
Reply
#2

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.
Reply
#3

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
Reply
#4

Awesome, I'm glad you fixed it!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)