Solved

passthru problem

Posted on 2004-08-19
2
929 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

831 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