accessing other apps

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

accessing other apps

Post by Deemo »

well, i am designing a small page that will allow me to view information that is viewed in a shell prompt. is there any way of doing that with php?

what i want it to do specifically is to execute a command in an existing shell, and then import the information and display it in a user friendly way

any help would be greatly appreciated

thanks
Deemo :o
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Try one of the program execution functions http://php.net/exec
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

thanks for the reply, and that does help

but i need to be able to access an already existing terminal. i have no idea how to do that.

for example:
lets say i have ./example running when i type in ps -eaf
how do i make it so i can "open" ./example so i can see all it returns?
if i want to go into ./example and run the command "status", i know i would use shell_exec() or something, but the program doesnt know which terminal to use the command "status" in.

this might seems confusing, but the way i imagine it is that then u use shell_exec() it activates its own new shell instead of an existing one.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Hmm, not sure that would be possible. If you have control over this shell script would it be possible for you to alter it, so that when you type 'status' it outputs and also outputs to a file, maybe status.txt, and have PHP parse this file rather than try to access the shell directly?
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

wont be able to do that because the program is already compiled and i dont think i will be able to get the source code

and if this isnt possible with php, what can it be made in?
d3ad1ysp0rk
Forum Donator
Posts: 1661
Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA

Post by d3ad1ysp0rk »

what about doing your first one, then closing that prompt and opening a new one..?
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

wont be able to do that

this is suposed to be like a "server tracker" for a game server i own, and to shut it down would be to drop clients :?

ive seen this done is ASP, is there no way to do this is php???
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

can no one figure this out???
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

You can try to start the program using the screen command. Then you can use [php_man]proc_open[/php_man] to connect a pipe to the program under the screen's control.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Here is an interesting thread on this topic: http://dbforums.com/arch/182/2003/1/670383
Post Reply