Solved

passthru problem

Posted on 2004-08-19
2
909 Views
Last Modified: 2008-02-26
i have linux servers and i want to execute commands in my box 1 using my box 2 using php. i read that passthru can do this but whenever i use it the command executes in box 2 and just outputs the result in box 1.

for example i use
passthru('ls');

the list of the current directory in my box 2 is listed instead of my box1. can anyone tell me if i am doing anything wrong. thank you.
0
Comment
Question by:teamasia
2 Comments
 

Expert Comment

by:iwarner
ID: 11849298
I would say that this is very unlikely, the security implications of running shell commands from one PC to another through one function is crazy.

I think you would have to open a permanent connection ie fsockopen and then run the commands you want.

0
 
LVL 2

Accepted Solution

by:
blackelvis earned 125 total points
ID: 11861771
you could place the php script in a directory underneath your document root on box 1 and password protect this directory. then in a php script on box 2 you can use passthru (or maybe exec suits you better?) to execute curl.

an example with exec:

exec ("curl --connect-timeout 30 --user yourlogin:yourpassword http://box1.domain.com/protected/remotescript.php", $returnedCurlOutput);
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now