Solved

passthru problem

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
str_replace not working in php script 4 30
php checkbox validation 5 27
PHP curl issue VERBOSE output 18 44
How to change the link of an image using md5 in php ? 3 32
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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…
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.

777 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