Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems with perl/cgi and rsh

Status
Not open for further replies.

GrahamBright

Programmer
Oct 31, 2003
65
AT
Hi all,

I'm trying to execute remotely commands from a perl/cgi script.

Working example (perl only)

$DATE=`exec rsh 10.236.137.41 date `;

however within my perl/cgi program if I try to print the value of DATE I get nothing back

Whats strange:

sub check_DATE()

{

open(MDATE, ">>$output") || die "Cannot open log file $!";

($MSISDN) = @_;

$DATE=`exec rsh 10.236.137.41 date`;
print DATE "date is $DATE";
close DATE;
}

resulting flat file contains only "date is " ?

If I provide an invalid IP address I can see that the webpage hangs, so it would appear that rsh is succeeding but no value for DATE.

Can you help or suggest alternatives where I can remotely execute commands from within a perl/CGI script.

Thanks,
Graham.

 
Have a look at Net::perl::SSH or in a LAN environment Net::Telnet, but there's serious security considerations with Net::Telnet outside a LAN, some would say even within a LAN

HTH
--Paul


cigless ...
 
Thanks Paul,

I found the problem which of course turns into another question. My cgi script executes as user so on the remote machine I get permission denied because this user a/c is not created.

I'm not sure of a way of getting around this without creating the user manually on the remote system.

system "rsh -l root 10.236.136.18 date > /tmp/test1.out 2>/tmp/test1.err";

shows on the local host

-rw-r--r-- 1 www 0 Jan 12 15:39 test1.out
-rw-r--r-- 1 www 19 Jan 12 15:39 test1.err
-rw-r--r-- 1 www 32 Jan 12 15:39 test.out

Thanks
Graham.
 
Thanks again,
Problem resolved, my cgi scripts execute under apache user created this user on the remote machine problem solved.

Graham.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top