LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 06-08-2010, 12:41 AM   #1
loftus49
Member
 
Registered: May 2010
Location: Phoenix
Distribution: Ubuntu, CentOS5, Fedora, Mint, MX Linux
Posts: 178
Blog Entries: 1

Rep: Reputation: 20
Error executing Perl/CGI script


I'm trying to install a HoneyPot in my RHFC6 server. When I try to execute it (./name.cgi) I get the following error:

[root@ip-xxxxxxxxxxx cgi-bin]# ./name.cgi
Content-Type: text/html
Cache-Control: no-cache

can't open : No such file or directory at ./name.cgi line 380.

When I vi the file name.cgi and go to line 380 I find:

380 open(FILE, "< $_[0]") or die "can't open $_[0]: $!";

What am I doing wrong?
Think I'll go back to spitting watermelon seeds.
 
Old 06-08-2010, 02:18 AM   #2
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Quote:
open(FILE, "< $_[0]") or die "can't open $_[0]: $!";
Line 380 above makes the name.cgi exit in case $_[0] (the first element in @_ array) cannot be opened with a filehandle.
Maybe you can add a print statement just before this line, to check the contents of @_ or $_[0]?

Usually, the @_ array is set from the results of previous code (that are not "caught" explicitly in variables). It's Perl's default
variable for storing everything.
 
Old 06-08-2010, 05:13 PM   #3
loftus49
Member
 
Registered: May 2010
Location: Phoenix
Distribution: Ubuntu, CentOS5, Fedora, Mint, MX Linux
Posts: 178

Original Poster
Blog Entries: 1

Rep: Reputation: 20
Quote:
Originally Posted by timmeke View Post
Line 380 above makes the name.cgi exit in case $_[0] (the first element in @_ array) cannot be opened with a filehandle.
Maybe you can add a print statement just before this line, to check the contents of @_ or $_[0]?

Usually, the @_ array is set from the results of previous code (that are not "caught" explicitly in variables). It's Perl's default
variable for storing everything.
OK. Sounds like a plan! But what print statement should be added just before this line?

Remember, I am the guy spitting watermelon seeds, not as proficient on this as I hope to be some day.
 
Old 06-09-2010, 02:11 AM   #4
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Something like
Code:
print join(" ", @_);
#or
print $_[0];
should do it.

I'm also wondering, since it's supposed to be a CGI script - what are the CGI parameters it ingests?
How is it supposed to be called from the web site?

So my guess is that the print will print an empty string ("").
Perhaps it could be useful to add something like
Code:
print "FILE - " $_[0] " -";
to make it stick out more.

Last edited by timmeke; 06-09-2010 at 02:15 AM.
 
Old 06-09-2010, 05:01 PM   #5
loftus49
Member
 
Registered: May 2010
Location: Phoenix
Distribution: Ubuntu, CentOS5, Fedora, Mint, MX Linux
Posts: 178

Original Poster
Blog Entries: 1

Rep: Reputation: 20
Quote:
Originally Posted by timmeke View Post
Something like
Code:
print join(" ", @_);
#or
print $_[0];
should do it.

I'm also wondering, since it's supposed to be a CGI script - what are the CGI parameters it ingests?
How is it supposed to be called from the web site?

So my guess is that the print will print an empty string ("").
Perhaps it could be useful to add something like
Code:
print "FILE - " $_[0] " -";
to make it stick out more.
OK. I'll try that in the morning. Thanks for your help.
 
Old 06-10-2010, 12:40 AM   #6
loftus49
Member
 
Registered: May 2010
Location: Phoenix
Distribution: Ubuntu, CentOS5, Fedora, Mint, MX Linux
Posts: 178

Original Poster
Blog Entries: 1

Rep: Reputation: 20
Quote:
Originally Posted by timmeke View Post
Something like
Code:
print join(" ", @_);
#or
print $_[0];
should do it.

I'm also wondering, since it's supposed to be a CGI script - what are the CGI parameters it ingests?
How is it supposed to be called from the web site?

So my guess is that the print will print an empty string ("").
Perhaps it could be useful to add something like
Code:
print "FILE - " $_[0] " -";
to make it stick out more.
OK ... tried that and got the following:

Scalar found where operator expected at ./name.cgi line 380, near ""FILE - " $_"
(Missing operator before $_?)
String found where operator expected at ./name.cgi line 380, near "] " -""
(Missing operator before " -"?)
syntax error at ./name.cgi line 380, near ""FILE - " $_"
Execution of ./name.cgi aborted due to compilation errors.

Here's the snip out of the file:

377 #################### PERL <-> PHP functions ################
378
379 sub file_get_contents {
380 print "FILE - " $_[0] " -";
381 open(FILE, "< $_[0]") or die "can't open $_[0]: $!";
382 undef $/;
383 my $whole_file = <FILE>; # 'slurp' mode
384 $whole_file =~ s/^#![a-zA-Z0-9\/\\\:\.\-\_\~ ]*[\n\r;]//;
385 close(FILE);
386 return $whole_file;
387 }
388
 
Old 06-10-2010, 03:41 AM   #7
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Sorry, that's right, we'll need to make it one string:

Code:
print "FILE - $_[0] -\n";
 
  


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
cgi script downloads - instead of executing sathiyamoorthy Linux - Server 1 04-23-2008 08:24 AM
executing perl cgi DanTaylor Programming 4 09-21-2006 06:54 PM
Permission denied executing cgi-script Geminias Linux - Networking 4 07-31-2006 10:02 PM
cgi-bin error regarding perl script hamish Linux - Software 11 12-09-2004 10:16 AM
Executing a program on server using CGi/PERl ?! avios Red Hat 1 12-29-2003 02:34 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 06: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