rsh + PHP how to program ??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bagava
Forum Newbie
Posts: 3
Joined: Fri Oct 04, 2002 6:03 am

rsh + PHP how to program ??

Post by bagava »

hi,


Well, I am looking for a way to integrate a UNIX command (rsh) into the function exec() from PHP but unfortunatly this command is not executed or at least a way to execute an external command (like rsh in Unix)... anyone have ideas ??? (by the way it is the same error with passthru, etc..)
Thank in advance for your help !

Code example :
$cmd ="ls -al";
$list = "rsh -l ems 10.1.1.1 \"exec ksh -c '. .profile;$cmd'\" > /tmp/list.txt";

exec($list);

$fp = fopen ("/tmp/list.txt","r");
echo "$fp";
:?:
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

The exec() & passthru() execute external programs, are you sure the command you are passing to the function is correct, try displaying the command instead of executing it. copy it to the command line and run it manually to see if it works!

if not what error message are you getting?
bagava
Forum Newbie
Posts: 3
Joined: Fri Oct 04, 2002 6:03 am

Post by bagava »

Thanks Wayne for your quick respond !

In fact I know this code works when using a Telnet cession.
Hereafter my following commands :

Code: Select all

$cmd ='ls -al'
then I type :

Code: Select all

rsh -l ems 10.1.1.1 "exec ksh -c '. .profile;$cmd'" > /tmp/list.txt
with 10.1.1.1 the remote host address.

And that works perfectly !!! :?

So then I have try to integrate that command into a PHP code I had
\
in fromt of
"exec
and
" >
to be compliant with the PHP code.

But nothing happen (no message error) only 1 has return value. :?:
Very strange I don't know what I should add into that PHP code.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

$output = array();
$lastline = exec ($cmd, $output, $retVal);
and take a look at the variables after exec (i.e. with print_r).
Maybe rsh is not in the path when executed by your php-script
bagava
Forum Newbie
Posts: 3
Joined: Fri Oct 04, 2002 6:03 am

Post by bagava »

thanks Volka,

But it doesn't work also.
In fact no error message... I should said I've no mesage at all... nothing can be read in the array.
Even I have try to sniff between the PHP server and the remotehost nothing ...any dialogues between both of them !
Very strange indeed it seems that the command exec understand unix function like (ls -al, whoamI,... etc but not the rsh command)

Nothing happen I have check also the path (is okay) I am able to execute the commande from the PHPserver when I logging into a linux cession but when I execute the PHP page nothing happen... I really don't what I should to do !! :(
Post Reply