Page 1 of 1
rsh + PHP how to program ??
Posted: Fri Oct 04, 2002 6:03 am
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";

Posted: Fri Oct 04, 2002 7:49 am
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?
Posted: Fri Oct 04, 2002 8:16 am
by bagava
Thanks Wayne for your quick respond !
In fact I know this code works when using a Telnet cession.
Hereafter my following commands :
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.
Posted: Fri Oct 04, 2002 8:46 am
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
Posted: Mon Oct 07, 2002 5:51 am
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 !!
