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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running unix command from webpage 1

Status
Not open for further replies.

thendal

Programmer
Aug 23, 2000
284
How to run a unix command from a web page...
I have unix command in the following path(solaris env) /opt/sys/rtool
this command helps to administer a portal software.

Here is the perl script to invoke the unix command


Code:
#!/usr/bin/perl
use CGI;
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/opt/sys';
$op=new CGI;
print $op->header;
$userid=$op->param('userid');
chomp($userid);
$out=`/opt/sys/rtool enable account $userid`;
print "<h4>Result: $out </h4>";

If i run this perl script in command line it works. If i run this from a web page gives me the following error message..

ERROR: TP_ROOT is not set. Set TP_ROOT in the shell environment or in $HOME/.tprc and rerun rtool.

TP_ROOT is /opt/sys i have added that in $ENV{'PATH'} is there something i am missing here...


Any suggestion or tips will be highly appreciated.

Thanks,
 
print the ENV hash from a CGI script to the screen and see what it looks like:

Code:
#!/usr/bin/perl
print "Content-type: text/html\n\n";

foreach my $var (sort keys %ENV) {
    print "<b>$var</b> = $ENV{$var} <br>\n";
}

then:

Code:
#!perl
use strict;
use warnings;
print "Content-type: text/html\n\n";
$ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin:/opt/sys';
foreach my $var (sort keys %ENV) {
    print "<b>$var</b> = $ENV{$var} <br>\n";
}

- Kevin, perl coder unexceptional!
 
Thanks Kevin, That worked I am able to set the missing env variables.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top