LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-07-2007, 09:40 PM   #1
adam_blackice
Member
 
Registered: Apr 2006
Location: /*Egypt */ //cairo
Distribution: Ubuntu 7.04 , SLED 10 , Fedora , RHEL 5
Posts: 312

Rep: Reputation: 32
error with cgi script !


hello all ..,

i want to make a simple cgi script that takes the command in the text field and then print back

in the next page ......,

first i create the form page that is command.pl

PHP Code:
#!/usr/bin/perl -w 

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


print
"<html><head><title>Linux Commands</title></head>";
print
"<body>";
print
"<H1>Enter Your Command</H1>";
print
"<form method='post' action='unix.pl'>";
print
"Command: <input type='text' name='command' size=40>";
print
"<br>";
print
"<input type='submit' value='Submit'><br>";
print
"<br>";
print
"<input type='reset' value='Clear'>";
print
"<br>";
print
"</form>";
print
"</body></html>"
second i made the action page (unix.pl) that the output will be printed in

PHP Code:
#!/usr/bin/perl -w
use CGI;
$cgi=new  CGI;

print 
$cgi->header();

print 
$cgi->body("<p><center><h1> Commands action page</p><center></h1>"), $cgi$


$command system "$input";

$input $cgi->param('command');

print 
"$command";

print 
$cgi->end_html(); 

i tried to run that but at the unix.pl page the output was 65280

what that number mean and that happened with any command .
 
Old 04-07-2007, 10:29 PM   #2
rtspitz
Member
 
Registered: Jan 2005
Location: germany
Distribution: suse, opensuse, debian, others for testing
Posts: 307

Rep: Reputation: 33
Quote:
$command = system "$input";

$input = $cgi->param('command');

print "$command";
if you REALLY want to do this, $input needs to be defined before you run the system-call !

your script does a system-call with a variable $input that is undefined! after that you grab your 'command' from your cgi-form and then your print $command.
 
Old 04-09-2007, 02:07 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Instead of
Code:
$command = system "$input";

$input = $cgi->param('command');

print "$command";
it would seem that you simply want
Code:
   print $cgi -> param( 'command' );
--- rod.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 09:10 PM
CGI script 500 error newuser455 Programming 8 06-11-2006 01:56 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
cgi-bin error regarding perl script hamish Linux - Software 11 12-09-2004 10:16 AM
Linux behind ISA cgi script is causing error malibuguy Linux - Security 1 12-27-2002 07:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:45 PM.

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