[PHP] PHP shell_exec

2007-02-27 Thread h
Hi 



I have been using the shell_exec command to perform several server queries 
quite succesfully i.e. analysing files systems by gettin ginformation returned 
by df -kP (shell_exec('df -kP')).  do any of you guts know if it is possible to 
target a command like this on another server? 



So from server A where I am running a web app, needs to run the shell_exec('df 
-kP') on server B, which also has php installed, so that i can display the 
results in my web app on server A.  Hope that makes sense!



Also, how would i fopen a file such as /proc/cpuinfo on Server B from Server A.



Any help greatly appreciated



Regards



Ade


Re: [PHP] PHP shell_exec

2007-02-27 Thread Németh Zoltán
2007. 02. 27, kedd keltezéssel 13.17-kor h ezt írta:
 Hi 
 
 I have been using the shell_exec command to perform several server queries 
 quite succesfully i.e. analysing files systems by gettin ginformation 
 returned by df -kP (shell_exec('df -kP')).  do any of you guts know if it is 
 possible to target a command like this on another server? 
 
 So from server A where I am running a web app, needs to run the 
 shell_exec('df -kP') on server B, which also has php installed, so that i can 
 display the results in my web app on server A.  Hope that makes sense!
 
 Also, how would i fopen a file such as /proc/cpuinfo on Server B from Server 
 A.
 
 Any help greatly appreciated
 
 Regards
 
 Ade

maybe you need ssh2_exec

http://hu.php.net/manual/hu/function.ssh2-exec.php

hope that helps
Zoltán Németh

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP shell_exec

2007-02-27 Thread Andrei

Hi Ade,

Sure you can. You must develop 2 scripts. One that will act as
server and one as client.
So if you want to get details of server B from server A you should
have the server into B and client into A.
Be sure the communication between these 2 servers is securised
(using a certificate or build you own encryption for communication,
restrict script response depending on server ips etc...) as you want to
pass sensitive data between them.
Communication can be done using curl library or simply with fopen
(if allow_url_fopen allows it). parameters can be passed using XML or
simple parsed plain text.

Andy

h wrote:
 Hi 



 I have been using the shell_exec command to perform several server queries 
 quite succesfully i.e. analysing files systems by gettin ginformation 
 returned by df -kP (shell_exec('df -kP')).  do any of you guts know if it is 
 possible to target a command like this on another server? 



 So from server A where I am running a web app, needs to run the 
 shell_exec('df -kP') on server B, which also has php installed, so that i can 
 display the results in my web app on server A.  Hope that makes sense!



 Also, how would i fopen a file such as /proc/cpuinfo on Server B from Server 
 A.



 Any help greatly appreciated



 Regards



 Ade

 .

   

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] PHP shell_exec

2007-02-27 Thread Peter Lauri
ssh2_exec would do it for you...

Best regards,
Peter Lauri

www.dwsasia.com - company web site
www.lauri.se - personal web site
www.carbonfree.org.uk - become Carbon Free



-Original Message-
From: h [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 27, 2007 3:18 PM
To: php-general@lists.php.net
Subject: [PHP] PHP shell_exec 

Hi 



I have been using the shell_exec command to perform several server queries
quite succesfully i.e. analysing files systems by gettin ginformation
returned by df -kP (shell_exec('df -kP')).  do any of you guts know if it is
possible to target a command like this on another server? 



So from server A where I am running a web app, needs to run the
shell_exec('df -kP') on server B, which also has php installed, so that i
can display the results in my web app on server A.  Hope that makes sense!



Also, how would i fopen a file such as /proc/cpuinfo on Server B from Server
A.



Any help greatly appreciated



Regards



Ade

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP shell_exec

2007-02-27 Thread Richard Lynch
On Tue, February 27, 2007 7:17 am, h wrote:
 I have been using the shell_exec command to perform several server
 queries quite succesfully i.e. analysing files systems by gettin
 ginformation returned by df -kP (shell_exec('df -kP')).  do any of you
 guts know if it is possible to target a command like this on another
 server?

 So from server A where I am running a web app, needs to run the
 shell_exec('df -kP') on server B, which also has php installed, so
 that i can display the results in my web app on server A.  Hope that
 makes sense!

 Also, how would i fopen a file such as /proc/cpuinfo on Server B from
 Server A.

Well, there are several options here.

One option is to just build a password-protected web page on the other
server that does the exec() (or readfile for cpuinfo).  Then you can
have PHP on server A do file_get_contents on the URL, if
allow_url_fopen is ON

Depending on how complex the target command is, you could also look
into running WebServices such as SOAP, RPC, REST, etc.

A valuable source of this kind of thing is from the zillion control
panels for webhosting that are out there

I think you might maybe be able to tunnel a command through SSH as a
one-off, but perhaps I'm just dreaming I read about that in man ssh a
few months ago.

To a large degree, HOW you do this depends much more on what commands
you want to allow, and even more importantly, disallow, than on
anything involving PHP.  In fact, PHP itself is only a
thinly-disguised wrapper for whatever you will come up with.  So
you're better off asking about this kind of thing on an OS or Linux
distribution mailing list, probably.  The PHP bit will end up just
being ?php exec($something)? no matter how you look at it.

-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php