LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-23-2006, 11:17 PM   #1
AgentRn007
LQ Newbie
 
Registered: Mar 2003
Posts: 12

Rep: Reputation: 0
Perl problems with system command


Hey everyone,

I am working on a simple perl script for school and am having an issue with outputting a ping command to a browser. Here is what is in my script and it use to work on Redhat 9 with Apache 2. I have Fedora 5 installed with the same config and it doesn't display the ping command. Any help would be appreciate.

Code :

#!/usr/bin/perl

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}

print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Ping results</TITLE>\n";
print "</HEAD>\n";
print "<BODY BGCOLOR=#FFFFFF LINK=#4133EF ALINK=FF0000 VLINK=#FF0000>\n";
print "<CENTER>\n";
print "<H1>Ping Results</H1>\n";
print "<BR>\n";
print "<P>\n";
print "<FONT SIZE+2>\n";
print "<P>\n";
print "<A HREF=$ENV{'HTTP_REFERER'}>\n";
print "Click here</A> To return to the previous page\n";
print "<BR>\n";
print "</FONT>\n";
print "<P>\n";
print "</CENTER>\n";
print "<PRE>\n";
system "ping -c $FORM{'pinter'} $FORM{'pnghost'}";
print "</PRE>\n";
print "<P>";
print "</BODY>\n";
print "</HTML>\n";

Thanks,
AgentRn007
 
Old 05-24-2006, 12:08 AM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Try replacing (example command):
Code:
system "ping -c5 192.168.0.1";
with:
Code:
print `/bin/ping -c5 192.168.0.1`;
Those are backticks, not single quotes.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find out if my system is i386, i486, or i586? Is there a system info command? mlsbraves Linux - General 6 02-17-2009 04:08 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM
Getting PID from a system command in Linux perl script sumbabs Linux - General 1 03-03-2005 10:38 AM
Help with System() command on linux PERL I R J Programming 2 01-05-2005 12:20 PM
command arguments in perl djgerbavore Programming 1 12-30-2004 08:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration