I
I
im_dimas2016-03-31 11:59:02
linux
im_dimas, 2016-03-31 11:59:02

How to make ssh2 script work?


PHP script not executing :

$output = $ssh2Lib->execute($link, "/home/cp/gameservers.py install $server[server_id] $server[game_code] $server[location_ip] $server[server_port] $server[server_slots] $server[server_password]");

necessary piece of code from gameservers.py
def serverInstall():
  os.system('useradd -m -g gameservers -p ' + crypt.crypt(password, salt) + ' ' + username)
  returnResult('ERROR', 'useradd -m -g gameservers -p ' + crypt.crypt(password, salt) + ' ' + username)
  for archive in gameConfig['Archives']:
    os.system('tar -xf /home/cp/gameservers/files/' + archive + '.tar -C /home/' + username + '/')
  os.system('chown ' + username + ' -Rf /home/' + username)
  os.system('chmod 700 /home/' + username)
  return True

Useradd doesn't work. If you do
/home/cp/gameservers.py start 14 crmb **.***.****.** 5022 40 pass
from the putty console, then useradd is executed.
Experts, tell me what I'm doing wrong?
PS: newbie

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor, 2016-03-31
@dimas199862

Most likely the problem is that it is not executed from the root user: 3
After all, from putty you come in as root

A
Alexander Urich, 2016-06-16
@Urichalex

Specify the full path to useradd in gameservers.py

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question