×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Perl scripts wont run, and can't figure out why

Perl scripts wont run, and can't figure out why

Perl scripts wont run, and can't figure out why

(OP)
My perl scripts wont run on server, but those that I download, configure, and upload work. I am running Win98 and am using the perl code editor to write/configure progs. I think the problem might be in the line endings, since the server is using unix.

theEclipse
robacarp.webjump.com

RE: Perl scripts wont run, and can't figure out why

Do they run on the desktop but not the server? If so, did you give them execute authority on the server? i.e.:

chmod 755 script.cgi

RE: Perl scripts wont run, and can't figure out why

One of the differences between Unix and Win/Dos is the way PATH is treated.

In DOS/etc - when you type a command the shell looks first in the current directory to execute a program - and only then searches the PATH variable to find it.

In Unix - the current directory is not searched when you try and run a program or script - only the $PATH variable.

You can get around this in two ways:

1) Keep all of the scripts/programs you want to run in a single directory - that is listed in your $PATH variable.

2) When you run a script - give the full path name to it. If you're in the same directory you could type ./prog to run prog.

Mike

Mike Lacey
Mike_Lacey@Cargill.Com
Cargill's Corporate Web Site

RE: Perl scripts wont run, and can't figure out why

What's the error message you get when you try to run the scripts on the server? This would indicate if it was a Unix problem, or a perl problem, and what the solution should be.

Let us know, and we'll see what we can do :)

RE: Perl scripts wont run, and can't figure out why

(OP)
well here are the answeres:
I don't know if the script would run on windows, that is I do not have a compiler for windows. maybee you can help me here too.

one error message I am getting is:
No such file or directory, and then it says something about checking my #! line. I did. it is correct.

the other error message I am getting is:
HTTP 500 - Internal server error

thanks for any help you can give.
robacarp.webjump.com

RE: Perl scripts wont run, and can't figure out why

You won't need to compile anything under Windows - the Win32 port is pre-compiled and just installs pretty much as any other Win32 package. Once installed, there's a 'perl2bat' utility which will massage Unix style perl scripts into runnable batch (.bat) files, which is handy. :)

Any chance you could cut & paste the actual error message into a posting? Also, if you could cut & paste the first few lines of your script as well, that might help some.

The HTTP error message you get is from the web server telling you the requested script CGI failed. If you have a look in the server error logs, you'll see the errors from your script. (Might be worth also cutting & pasting these into a post as well.)

thanks,
Andy

RE: Perl scripts wont run, and can't figure out why

(OP)
Kay.

1) where do i get this perl2bat utility, and what good does having a runnable batch file do for me.

2)here is the error, cut and paste:

CGI Error: Script Execution Failed

--------------------------------------------------------------------------------

CGI encountered an error while attempting to execute this script:

Error Message: No such file or directory
Error Number: 2
This message usually indicates there is a problem with the script itself. The owner of the script needs to check the #! line for correctness.


3)here is the whole script(it is not very long):

#!/usr/local/bin/pearl
#this is my basic starter program!!!
#remember, i am just getting my feet wet!!!

#this gets information from one field

$fieldContents = param("myField");
print "Content-Type: text/html\n\n";
if ($fieldContents eq "010203"){
print("correct, you got it correct");
}else{
print("Wrong, hahaha");}


please critique and correct this code, but when you do, please remember to tell me why it needs to be that way, so i wont forget.

thanks for all your help,
theEclipse
robacarp.webjump.com

P.S.
if you want to see one of my scripts(or sort of) in action(what little they do), goto: http://robacarp.webjump.com/cgi-bin and try either mypearl.pl, or mypearl2.pl (i know it is spelled wrong)

RE: Perl scripts wont run, and can't figure out why

Bingo! As Mike says, looks like that 'pearl' is the culprit.

pl2bat is a utility you get with perl for Win32. Feed it the name of a Unix perl script you've built and copied to the Win32 machine, and it wraps it up in the necessary MS-DOS batch code to make it run. It then renames the perl script to add a ".bat" extension on the end so that Windows/MS-DOS will run it.

HTH

RE: Perl scripts wont run, and can't figure out why

Sounds like a solution! Hope it works out for you.

I have a question. From what I know - and I'm still learning - there are two ways of getting POST data. One is via:

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

You then need to parse out the variables from $buffer. The other method is to use the CGI module and call its methods. For example:

use CGI;

$objCGI = new CGI; # CGI Object

print $objCGI->param('Phone1');


The script in the last post uses "param" but it does not explicitly use the CGI module. Is CGI used as a default for this installation of perl?

Any input would be appreciated.

RE: Perl scripts wont run, and can't figure out why

(OP)
wow, i guess that shows what happens when you spell something wrong, and I feel really stupid for dong that,

but

the script still dosn't work :-(

aaaaaaaahhhhhhhhhhh

this time, I tried using a much simpler script, 3 lines:

#!/usr/local/bin/perl
print "Content-Type:text/html\n\n";
print "The test program has run succesfully!!!";

spelled perl correctly, checked the directory, everything should work just fine--but--same errors


I dont have a clue what to do.


and where can I get that pl2bat thingy???
theEclipse
robacarp.webjump.com

RE: Perl scripts wont run, and can't figure out why

The pl2bat utility is actually known as pl2bat.bat and should be found in your Win32 perl\bin directory. For example, "c:\perl\bin\pl2bat.bat".

On the script not running side of things, have you got execute permissions set on the new script? If so, it may be time to look at the HTTP server. Is the CGI directory set up in the web server as being a valid CGI directory? Just a thought.

RE: Perl scripts wont run, and can't figure out why

pl2bat.bat is for converting unix scripts to run on NT. I thought you wanted a script that will work on unix?

Try these steps - from the shell prompt and in your home directory:

--snip--
cat > atest.pl <<!
#!/usr/local/bin/perl
print "hello world\n"
!
chmod +x atest.pl
./atest.pl
--snip--

Type everything between the --snip-- lines exactly as shown. After the last line you should see "hello world" printed. This will verify that perl is there.

Mike

Mike Lacey
Mike_Lacey@Cargill.Com
Cargill's Corporate Web Site

RE: Perl scripts wont run, and can't figure out why

(OP)
Do what now?

ok. slow down. maybee even stop. I dont currently have unix shell access. and I want scripts to run on both the webjump server and my pc. I looked and there is no pl2bat.bat file on my system, and the servers permissions are automatically set. I have also activated the cgi-bin

thanks for ur help
theeclipse
robacarp.webjump.com

RE: Perl scripts wont run, and can't figure out why

not sure but check the perl version, some administrators upgrade perl into diffrent folders. i.e. you may have /usr/local/bin/perl, but the admin may have installed the perl ino /usr/local/bin/perl5 or something like that. Check with the admin and if you can have someone or yourself on the web server type perl -v or perl5 -v on the command line to find out what version it is running and try whereis perl or whereis perl5

This code:

#!/usr/local/bin/perl

### This part here is correct. I believe your problem is in the line above this one #####
print "Content-Type:text/html\n\n";
print "The test program has run succesfully!!!";

also it has to be executable by everyone, so check the file permissions and make sure perl is installed and is running correctly on the server.
You are on the right track!

RE: Perl scripts wont run, and can't figure out why

(OP)
thanks for all of your help

I am kinda new... ok ok ok really new at this, and the scripts not working is not helping at all. I will check and see about the permissions and the perl 5 location, but I think that is the correct location. get back to ya


theEclipse
robacarp.webjump.com

RE: Perl scripts wont run, and can't figure out why

(OP)
Well,

I checked the permissions, and the location of perl. They say that their servers wont run scripts that require permissions of over 755. and the permissions are set globally, and cannot be changed on an individual basis.


they have a script on the server that works just fine, and I have included it in this post, below.

thanks again
theEclipse
robacarp.webjump.com



#!/usr/local/bin/perl
#print "HTTP/1.0 200 OK\n";
$cooky=$ENV{'HTTP_COOKIE'};
$cooky=~s/(\s*)//g;
@cookieArray=split(/;/, $cooky);
foreach $i (@cookieArray) {
($CookieArrayRowFirst, $CookieArrayRowSecond)=split(/=/, $i);
$COOKIE{$CookieArrayRowFirst}=$CookieArrayRowSecond;
}
$COOKIE{'samcookie'}=$COOKIE{'samcookie'}+1;
print "Set-cookie: samcookie = $COOKIE{'samcookie'}\n";
print "Content-Type: text/html\n\n";

print "<html><head><title>New Page 2</title>";
print "<meta name=\"GENERATOR\" content=\"Microsoft FrontPage 3.0\">";
print "</head><body><p align=\"center\"> </p>\n";
print "<p align=\"center\"><big><big><font color=\"#FF0000\">\n";
print "WELCOME TO PERL!</font></big></big></p>";
print "<p>";
print "$PATH_INFO";
print "</p>";
foreach my $envkey (%ENV)
{
print "<p>$envkey</p>";
}

read(STDIN, $poststring , $ENV{'CONTENT_LENGTH'});
print "$poststring";
print "<p align=\"center\"> </p>";
print "<div id=virtavebanner style=\"visibility:hidden; position:absolute;\">";
print "<!--VirtualAvenueBanner-->";
print "<br>";
print "<br>";
print "</div>";
print "</body></html>";
__END__



that is the script that works on the server, I have examined it and cut and pasted from it, and mine still dont work.

RE: Perl scripts wont run, and can't figure out why

What happens if you run the script using perl? ie, at the command line, type:

perl myscript.pl

Does it work then? If it does, what permissions are set on your script? ie:

ls -l myscript.pl
-rwxr-xr-x 1 someuser other 3095 Feb 07 2000 myscript.pl

Your permissions should look like those in the example. (rwxr-xr-x).

HTH.

RE: Perl scripts wont run, and can't figure out why

(OP)
What command line? where?

if you mean run the script, well it works, and outputs a whole bunch of information on the server, and perl.


I am starting to think that a different server might be in order. Do you know of any that host cgi and are free (the budget is a little tight latley)or dirt cheap

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close