Using SSH on PHP help (SA-MP Commands)
#1

Hello,

I am making a SA:MP panel with 3 options: Start, Pause and Restart.
The thing is, I made the connection to the linux user successfully, but the starting samp server command is not working, and I don't know why. Here is the code:
PHP код:
echo $ssh->write('cd samp01\n'); // Changing to 'samp01' directory
echo $ssh->write('./samp03svr &\n'); // Starting the server 
I have a 'samp01' folder inside of the user folder so I have to do 'cd'.
However, when I make these commands on Putty it works great.
Any ideas?

By the way, I am using phpseclib.
Reply
#2

See if the working directory for the plugin is the same as the putty working directory by using pwd.
Reply
#3

Quote:
Originally Posted by SKAzini
Посмотреть сообщение
See if the working directory for the plugin is the same as the putty working directory by using pwd.
May you explain yourself better please? thanks for reply though
Reply
#4

PHP код:
echo $ssh->write('pwd\n'); 
Try this, it should (I'm not experienced with this plugin) print your working directory.

What does it return?
Reply
#5

Quote:
Originally Posted by SKAzini
Посмотреть сообщение
PHP код:
echo $ssh->write('pwd\n'); 
Try this, it should (I'm not experienced with this plugin) print your working directory.

What does it return?
/home/samp01 (the user is samp01, but there is a directory in it called 'samp01' either)
Reply
#6

PHP код:
echo $ssh->write('nohup ./samp03svr &\n'); 
Try this.

If that doesn't work, please print the folders in your home directory:

PHP код:
echo $ssh->write('dir\n'); 
And in your server folder:

PHP код:
echo $ssh->write('dir samp01\n'); 
Reply
#7

Quote:
Originally Posted by SKAzini
Посмотреть сообщение
PHP код:
echo $ssh->write('nohup ./samp03svr &\n'); 
Try this.

If that doesn't work, please print the folders in your home directory:

PHP код:
echo $ssh->write('dir\n'); 
And in your server folder:

PHP код:
echo $ssh->write('dir samp01\n'); 
Before I do that, I am not sure if I have to use 'write' or 'exec'.
When I use 'write' it like writes '1' as output, but when I used 'exec' it doesn't give any output (as needed I guess).
Anyways, I used:
PHP код:
echo $ssh->exec('cd samp01');
echo 
$ssh->exec('nohup ./samp03svr &');
echo 
$ssh->exec('dir'); 
Output: 'samp01'

--

EDIT: In my server folder:
PHP код:
echo $ssh->exec('dir samp01'); 
Output: LICENSE announce gamemodes npcmodes samp03svr server.cfg README filterscripts include samp-npc scriptfiles server_log.txt
Reply
#8

Strange..

PHP код:
echo $ssh->exec('nohup ./samp03svr &'); 
Should work..

Well, I'll try the plugin on my webserver and see if it works for me, posting the results in a while.
Reply
#9

Quote:
Originally Posted by SKAzini
Посмотреть сообщение
Strange..

PHP код:
echo $ssh->exec('nohup ./samp03svr &'); 
Should work..

Well, I'll try the plugin on my webserver and see if it works for me, posting the results in a while.
I just realised that "echo $ssh->write('cd samp01\n');" doesn't really change the directory, which means the command is not even working. I have no clue why and how, but I will keep trying.

However, thank you very much!
Reply
#10

Yeah, I just realised that too.

Workaround:

PHP код:
echo $ssh->exec('(cd samp01 ; nohup ./samp03svr &)'); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)