httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "amit khatri" <>
Subject Running perl script to execute system commands ( script included )
Date Thu, 28 Feb 2002 13:14:36 GMT


    This is the perl script to run a system command(on linux) .

The commands are send from an html page whose code is also included.

U can save the code and try running it.

( I log in as root user )

Problem :
          Commands that run are


          Commands that don't run are

                                  ipchains -n -L
                                  mount /dev/fd0

         it also doesn't show any error for invalid commands.

I want all commands to be executed.

I have not used any module in perl code,is that the reason.
If that is the reason which module should be used and how to install
that module on linux machine

#------------------  Perl Code ( --------------------------

print "Content-type: text/html\n\n";

read(STDIN,$in,$ENV{'CONTENT_LENGTH'});   #reads the input in var 'in'

@in=split(/&/,$in);    #split the name value pairs

($name1, $val1)=split(/=/,$in[0],2);  #save the first name and value
($name2, $val2)=split(/=/,$in[1],2);  #save  the second name and value

$val2=~ s/\+/" "/ge;   #replace the '+' sign with spaces

# The following 4 lines appends the second value to first , to form a   
complete command

$temp=~ s/%(..)/pack("c",hex($1))/ge;

# the appended command is stored in the command variable


# by including the `command` var in backquotes it is executed.

# u can directly try @ans=`ls`;


# The output is send in html format in new window

print "<HTML>";
print "<body bgcolor='brown'>";

print "<hr>";
print "<h1>";

foreach $i(0 .. $#ans)
print "$ans[$i] <br> ";

print "</h1>";

print "</body>";
print "</HTML>";

#--------------------------Perl Code Ends---------------------------

--------------------------  HTML CODE-------------------------------


<form method="post" name="form" target="new"

<h2> Command <input type="text" name="command">
<h2> Parameter <input type="text" name="parameter">
<input type="submit">


------------------------- HTML Code Ends  --------------------------

PL try running it and reply me the solution to it.


Amit Khatri

>From: Pietro Cagnoni <>
>Subject: Re: running system commands using perl script on linux
>Date: Wed, 27 Feb 2002 14:37:10 +0100
>amit khatri wrote:
> >
> > I am running as a root and even the simple commands like "ll"
> > don't work.
> > At least it should give me the error messages for invalid commands.
>hm, ll usually is not a single command but a shell alias... what if you
>try ls?
>is there anything in the error log? do you get any message in the
>in case of despair, post the script.
>The official User-To-User support forum of the Apache HTTP Server Project.
>See <URL:> for more info.
>To unsubscribe, e-mail:
>For additional commands, e-mail:

Join the world’s largest e-mail service with MSN Hotmail.

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message