Solved

passthru problem

Posted on 2004-08-19
2
940 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.  …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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.

688 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