I'm looking for some insight to the following code. I don't understand why
when I uncomment the #$command="/usr/local/apache/cgi-bin/port-reset.exp
$portnumber"; and comment the ls command it does not execute successfully.
When the code is as below everything works fine, but switching the commented
lines cause it to fail. I send the results of $command to a file and it
looks fine, I can even copy and paste the output, as any user, and it
executes fine, it just won't execute successfully when I call it from a web
page. Any assistance would be appreciated.
## Code begins
print "Content-type: text/html\n\n";
print "<HTML><BODY bgcolor=#483d8b><FONT COLOR=\"yellow\">";
print "<CENTER>";
$portnumber = $in{'PORT'}; #Value passed in from the
/usr/local/apache/htdocs/port-reset/index.html page
#$command="/usr/local/apache/cgi-bin/port-reset.exp $portnumber"; ## This
command will only execute from a command line and not from within this
script
$command="/usr/bin/ls -al > /tmp/file2"; # This works fine, so I comment
this line, uncomment the above and the script fails. Why?
$result = system("$command");
if ($result) {
# $? is the exit code.
print "<h1>Unable to reset port $portnumber. Contact support.\n";
}
else {
#It exits 0 if successfully
print "<h1>Port $portnumber has been reset.";
}
################################################## ############
# This logs all page sent through the web
################################################## ############
$Time = localtime;
open(OUTFILE, ">>/usr/local/apache/logs/port-reset.logs");
print OUTFILE
("\"$Time\",\"$ENV{'REMOTE_ADDR'}\",\"$portnumber\ ",\"$command\"\n\"");
exit;
## Code ends 2 2708
"Me" <an*********@netzero.net> wrote in message
news:SE*********************@news20.bellglobal.com ... I'm looking for some insight to the following code. I don't understand why when I uncomment the #$command="/usr/local/apache/cgi-bin/port-reset.exp $portnumber"; and comment the ls command it does not execute successfully. When the code is as below everything works fine, but switching the
commented lines cause it to fail. I send the results of $command to a file and it looks fine, I can even copy and paste the output, as any user, and it executes fine, it just won't execute successfully when I call it from a
web page. Any assistance would be appreciated. ## Code begins print "Content-type: text/html\n\n"; print "<HTML><BODY bgcolor=#483d8b><FONT COLOR=\"yellow\">"; print "<CENTER>";
$portnumber = $in{'PORT'}; #Value passed in from the /usr/local/apache/htdocs/port-reset/index.html page
#$command="/usr/local/apache/cgi-bin/port-reset.exp $portnumber"; ## This command will only execute from a command line and not from within this script $command="/usr/bin/ls -al > /tmp/file2"; # This works fine, so I comment this line, uncomment the above and the script fails. Why?
$result = system("$command"); if ($result) { # $? is the exit code. print "<h1>Unable to reset port $portnumber. Contact support.\n"; } else { #It exits 0 if successfully print "<h1>Port $portnumber has been reset."; }
################################################## ############ # This logs all page sent through the web ################################################## ############ $Time = localtime; open(OUTFILE, ">>/usr/local/apache/logs/port-reset.logs"); print OUTFILE ("\"$Time\",\"$ENV{'REMOTE_ADDR'}\",\"$portnumber\ ",\"$command\"\n\""); exit; ## Code ends
Use sudo to give apache permission to execute.
--
-linux_lad
To verify that this post isn't forged, click here: http://www.spoofproof.org/verify.php...543a73889e4706
I can execute the command at the command line as nobody, so I don't think
using sudo would help. I'll give it a try anyways.
"-linux_lad" <john AT linuxlad DOT org> wrote in message
news:kf********************@giganews.com... "Me" <an*********@netzero.net> wrote in message news:SE*********************@news20.bellglobal.com ... I'm looking for some insight to the following code. I don't understand
why when I uncomment the #$command="/usr/local/apache/cgi-bin/port-reset.exp $portnumber"; and comment the ls command it does not execute
successfully. When the code is as below everything works fine, but switching the commented lines cause it to fail. I send the results of $command to a file and it looks fine, I can even copy and paste the output, as any user, and it executes fine, it just won't execute successfully when I call it from a web page. Any assistance would be appreciated. ## Code begins print "Content-type: text/html\n\n"; print "<HTML><BODY bgcolor=#483d8b><FONT COLOR=\"yellow\">"; print "<CENTER>";
$portnumber = $in{'PORT'}; #Value passed in from the /usr/local/apache/htdocs/port-reset/index.html page
#$command="/usr/local/apache/cgi-bin/port-reset.exp $portnumber"; ##
This command will only execute from a command line and not from within this script $command="/usr/bin/ls -al > /tmp/file2"; # This works fine, so I
comment this line, uncomment the above and the script fails. Why?
$result = system("$command"); if ($result) { # $? is the exit code. print "<h1>Unable to reset port $portnumber. Contact support.\n"; } else { #It exits 0 if successfully print "<h1>Port $portnumber has been reset."; }
################################################## ############ # This logs all page sent through the web ################################################## ############ $Time = localtime; open(OUTFILE, ">>/usr/local/apache/logs/port-reset.logs"); print OUTFILE ("\"$Time\",\"$ENV{'REMOTE_ADDR'}\",\"$portnumber\ ",\"$command\"\n\""); exit; ## Code ends
Use sudo to give apache permission to execute.
-- -linux_lad To verify that this post isn't forged, click here: http://www.spoofproof.org/verify.php...543a73889e4706
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: redneck_kiwi |
last post by:
Hi all:
I have a really weird problem. I am developing a customer catalog
system for my company and as such have delved into sessions for
authentication and access levels. So far, I have managed...
|
by: ThunderMusic |
last post by:
Hi,
I'm trying to have a MSN Messenger like form/app closing behavior. When I
click on the X button, I only want the form to disappear and when I
double-click on the notify icon or right-click...
|
by: Angel Mazo |
last post by:
Dear all,
I have a very weird Access 97 MDE behavior that I don't know how to
explain and, of course, how to solve:
.. I have a site with 14 PC's, mixed Windows XP Pro and Windows 98,
running...
|
by: ncf |
last post by:
Ok, I've been tring to resolve this issue for some time now (~1 day
which is way longer than normal for me) to no avail.
I am reading a file into a list in memory, using a "%" delimited file...
|
by: Jonathan Yong |
last post by:
I observe a very weird behavior when dynamically create web control
and bind events to it.
Create a C# ASP.NET application,
Put a PlaceHolder and Textbox onto the Web form,
and try with the 4...
|
by: Me |
last post by:
I'm getting a NullReferenceException in Unknown Module when I follow
the below steps to create a simple NotifyIcon app that creates the
context menu on the fly(see a little analysis after the...
|
by: Wayne Dyer |
last post by:
I can duplicate this, so I know it's not something I'm imagining and
wonder if anyone else has seen it.
Take a page, put a drop down control on it, hook up the onChange event
handler to go get...
|
by: Charles Law |
last post by:
For some reason, when I click the X to close my MDI parent form, the action
appears to be re-directed to one of the MDI child forms, and the parent
remains open. I am then unable to close the...
|
by: XYZ |
last post by:
I need to pass the address of a variableto some win32 API functions like
RTLMoveMemory
I noticed some weird behavior when pinning objects and using the handle's
pointer to write data to the...
|
by: Ben |
last post by:
Hi,
i have a weird problem and i don't know who is responsible for this: IIS,
excel or asp.net.
My problem:
we use an asp.net 2.0 application under IIS 6.0 (server 2003 sp2) which must
write...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |