Jump to content

[SOLVED] system command


AV1611

Recommended Posts

I've seen this question before, but never gotten a good answer to it:

 

I want to start a problem on my linux box via my personal web site.  I know it's possible with PHP because I use webmin to start and stop programs all the time. 

 

I know it's more than a simple string, as I have to log to the local machine etc.

 

Can someone point me in the right direction or a howto or tutorial or something?

 

Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/84178-solved-system-command/
Share on other sites

No, that won't work.  If you do

 

exec('xterm');

 

it doesn't start an xterm on the server. (it doesn't show up in "top".)

 

The program I want to run is not xterm, but it will do for this discussion.

 

I think apache user is not allow to start local processes, so there's a mod that webmin uses or something.

 

If I do

$e=exec('ls');

echo $e

 

it works.

Link to comment
https://forums.phpfreaks.com/topic/84178-solved-system-command/#findComment-428528
Share on other sites

The reason xterm will fail is because it will fail to find a display (a window). Its not called xterm for nothing, and needs to be called from within an x windows system.

 

Exec will give you direct access to the shell however and can easily execute programs which have a command line interface. What program do you wish to run exactly?

Link to comment
https://forums.phpfreaks.com/topic/84178-solved-system-command/#findComment-428540
Share on other sites

Ah, that makes sense about no x handle

 

I run an america's army server, for example.  It's not up all the time.  I want to create a way to start it up via a web page. (I can do it via ssh, but don't like giving ssh out to people...)

 

The command is "/path/to/file/server-bin -some -switches"

 

via ssh I use "&" so I can close the session and leave the server running.  I don't need to be able to kill the server, but may change my mind on that...

 

 

Link to comment
https://forums.phpfreaks.com/topic/84178-solved-system-command/#findComment-428586
Share on other sites

Actually, thinking about the jail. Unless the program your trying to execute is within the same filesystem (which it does not look like) then you won't be able to execute it.

 

The entire /home directory will not exist within the chroot environment. Sorry I didn't click to it earlier but I should imagine that is your problem. the only work around I can see would be to install the application within the same chroot.

Link to comment
https://forums.phpfreaks.com/topic/84178-solved-system-command/#findComment-428801
Share on other sites

Let's review:

 

Because the virtual domain is chrooted to /var/www/virtualname/ then /home doesn't exist.  "/" is actually "/var/www/virtualname/" 

 

If I

mkdir /var/www/virtualname/home

 

then  copy

/home/username/foldername

to

/var/www/virtualname/home/foldername

 

all is well.

 

Is my understanding of how the chrooted jail work correct?

 

 

Link to comment
https://forums.phpfreaks.com/topic/84178-solved-system-command/#findComment-428807
Share on other sites

Is my understanding of how the chrooted jail work correct?

 

Your understanding of a chroot seeams sound.

 

I suppose it depends on what exactly this server-bin file is. Is it the complete executable for this server? How in fact did you install this server application? Is it linked to the actual system in any way?

 

 

Link to comment
https://forums.phpfreaks.com/topic/84178-solved-system-command/#findComment-428811
Share on other sites

I untared and mod'ed the ini's.  no install, no compiling. 

 

I did notice that when I try to execute it with ssh it gives me an error if I don't do it from the

/home/username/aops-lnxded-2.8.1/System folder.

 

It complains about not finding ../System/somefile

 

I make a shell script that does

cd /path/to/System

/path/to/server-bin

then did

exec('sh /path/to/file.sh');

but it still doesn't work,

but the sh works in ssh from anywhere.

 

 

Link to comment
https://forums.phpfreaks.com/topic/84178-solved-system-command/#findComment-428817
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.