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
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
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
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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.