Solved

my perl script doesnot execute !

Posted on 1998-07-21
53
176 Views
Last Modified: 2013-12-25
I have a script which works fine in my old UNIX web server. When In moved to NT I have a lot of problems. When I submit, I wait until I get the time out message from the browser ? Can you help please. Thanks

Wal
0
Comment
Question by:waleed072098
  • 34
  • 19
53 Comments
 
LVL 6

Expert Comment

by:alamo
ID: 1830873
First thing to try: an extremely simple one line script:

print "Content-Type: text/plain\n\nIt worked\n";

This will make sure your server is set up to run perl scripts properly. In NT on IIS you need to set up the registry script mappings so that .pl calls perl.

What kind of server? What version of perl? perlis or perl.exe?
0
 

Author Comment

by:waleed072098
ID: 1830874
To alamo
The registry script mappings is setup.
Server is  IIS3
Perl version is Perl5
Perl.exe

Thanks
0
 

Author Comment

by:waleed072098
ID: 1830875
To alamo
The registry script mappings is setup.
Server is  IIS3
Perl version is Perl5
Perl.exe

Thanks
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830876
Does the test script I posted work? If so, something about your script. (You probably knew this, but I wanted to double-check).

What does the script do? Does it call system or invoke any other processes?
0
 

Author Comment

by:waleed072098
ID: 1830877
Nothing happend. Still hanging until I got the time out message.

By the way what is "nIt" Is it N L T in lowercase ?
0
 

Author Comment

by:waleed072098
ID: 1830878
sorry it is like this .\n\n it worked. Ok but it still hanging like loading .
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830879
The n was the last part of \n, my one-liner was the equivalent of

print "Content-Type: text/plain\n\n";
print "It worked\n";

which is as simple as you can get.

So possibly your script mappings aren't working, if the simplest perl script won't run, yet doesn't give an error. On mu machine (an older version of IIS but I think the mapping is the same) the key is
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Script Map
and the value and data is
".pl"="d:\programs\perl5\bin\perl.exe %s %s"

Obviously the path to perl will be different, but the %s %s after it is the critical thing.

How does this differ than yours?
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830880
Just saw your last post, hadn't seen it before I just posted it.

If you see \n in your test script, you are using single-quotes instead of double-quotes, use double quotes and the entire page should be
It worked
0
 

Author Comment

by:waleed072098
ID: 1830881
mine is like this
".pl"="c:\perl\perl5\bin\perl.exe"
I added the %s %s
and become like this
".pl"="c:\perl\perl5\bin\perl.exe %s %s"

and then I executed it opens the File Download Window

                              Open this file....
                              Save this fille...
0
 

Author Comment

by:waleed072098
ID: 1830882
mine is like this
".pl"="c:\perl\perl5\bin\perl.exe"
I added the %s %s
and become like this
".pl"="c:\perl\perl5\bin\perl.exe %s %s"

and then I executed it opens the File Download Window

                              Open this file....
                              Save this fille...
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830883
If you choose "Save this file" and look at the file, what is it?
0
 

Author Comment

by:waleed072098
ID: 1830884
Ok I did. It save my perl file which is

test.pl

and the content:

# ! /usr/local/bin/perl             <---------that's from unix not my actual perl path.
print "Content-Type: text/plain\n\nIt worked\n";
0
 

Author Comment

by:waleed072098
ID: 1830885
Ok I did. It save my perl file which is

test.pl

and the content:

# ! /usr/local/bin/perl             <---------that's from unix not my actual perl path.
print "Content-Type: text/plain\n\nIt worked\n";
0
 

Author Comment

by:waleed072098
ID: 1830886
Ok I did. It save my perl file which is

test.pl

and the content:

# ! /usr/local/bin/perl             <---------that's from unix not my actual perl path.
print "Content-Type: text/plain\n\nIt worked\n";
0
 

Author Comment

by:waleed072098
ID: 1830887
Ok I did. It save my perl file which is

test.pl

and the content:

# ! /usr/local/bin/perl             <---------that's from unix not my actual perl path.
print "Content-Type: text/plain\n\nIt worked\n";
0
 

Author Comment

by:waleed072098
ID: 1830888
Ok I did. It save my perl file which is

test.pl

and the content:

# ! /usr/local/bin/perl             <---------that's from unix not my actual perl path.
print "Content-Type: text/plain\n\nIt worked\n";
0
 

Author Comment

by:waleed072098
ID: 1830889
Ok I did. It save my perl file which is

test.pl

and the content:

# ! /usr/local/bin/perl             <---------that's from unix not my actual perl path.
print "Content-Type: text/plain\n\nIt worked\n";
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830890
The server no longer recognizes .pl as a script, strange. Try stopping and restarting the server so it rereads the registry. Also make sure the directory the script is in is marked in the Internet Service Manager as an execute directory as well as read.
0
 

Author Comment

by:waleed072098
ID: 1830891
yes strange but at the command line, I can execute the test.pl just by typing the name of the file and return  w/o perl (i.e c:\test.pl ) so the computer understands the extension.

The script is under  c:\inetpub\wwwroot\cgi-bin

It is there  in the internet service manager

But should it be under scripts eventhough it is given the same thing ?
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830892
It doesn't need to be in scripts as long as intenet service manager shows cgi-bin as having both read and execute rights. You could try it in scripts just to see if anything is different.

The way IIS works, it needs the script-mappings in the registry rather than extension like you would use from the command line.
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830893
I did some testing, and it looks like it no longer sees .pl as a script type. One thing that occurred to me is when I posted

".pl"="c:\perl\perl5\bin\perl.exe %s %s"

I was using the format exported by regedit - and regedit adds double quotes to the .pl. If you added them on your system it would explain it. I just cehcked regedit and on my system .pl shows without quotes, "c:\perl\perl5\bin\perl.exe %s %s" shows with quotes. So maybe you should double check that entry. I think you're close.
0
 

Author Comment

by:waleed072098
ID: 1830894
Sorry It is not in double quotes. It is like this:

pl=c:\perl\perl5\bin\perl.exe %s %s

No quotes ata all.

Still not working
0
 

Author Comment

by:waleed072098
ID: 1830895
Sorry It is not in double quotes. It is like this:

pl=c:\perl\perl5\bin\perl.exe %s %s

No quotes ata all.

Still not working
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830896
Hi again waleed,

Maybe it was just a typo in what you posted, but it needs to be .pl (with the dot preceding it) not just pl

I have completely reconstucted your situation. Here's what I did:

1. I changed My Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters\Script Map value for .pl to d:\programs\perl5\bin\perl.exe
I then had exactly the same problem you had originally - the server waited until timeout.

2. I then renamed the .pl key above to pl. After stopping and restarting the server, I then saw exactly what you are seing - it didn't recognize that it was a script at all, and gave me Save As window just like it is for you now.

3. I then renamed the above pl back to .pl and added %s %s to the end of the value, and after restarting the server it all worked for me.

That's why I think there's just a minor editing problem here - I can duplicate everything you are seeing happen by making changes to that key.
0
 

Author Comment

by:waleed072098
ID: 1830897
Hi alamo,
Sorry for bothering you again.
It is always .pl with a dot but I forget it when I post it.

Her is what I have
pl:REG_SZ : C:\perl\perl5\bin\perl.exe %s %s

Thanks again
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830898
Let's step back and make sure the server is seeing that entry - it seems to me it isn't but the entry looks fine to me.

Change the value back to its original, that is remove %s %s from the string. What should happen is the original problem - never responding and then timing out - should return. This will prove that it's seeing that entry in the registry.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:waleed072098
ID: 1830899
I removed %s %s from the string. The result is no respond and thentimeout.

Waleed
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830900
Ok, that proves that it's seeing that entry, it considers your script a script, and is running perl.
 
When the %s %s is there, the fact that you get a Save dialog and when you save it you got a copy of your script shows that it's not seeing your script as a script, and isn't running perl.

That's what I don't understand. It makes no sense. I could understand it if you were running IIS4, but not on IIS3.

Let's try adding the %s %s back to the registry entry, then insert the following line into your test script at the top.

print "HTTP/1.0 200 OK\n";

It should make no difference, but...
0
 

Author Comment

by:waleed072098
ID: 1830901
Can you wait until tomorow morning. Actually, maybe it is ISS4.
I am not really sure if I upgrade it or not and I can't check it now. I have some lectures to attend the rest of the day. Do you mind waiting till tomorrow. Thanks alot.

Waleed
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830902
Sure, no problem! That would explain why things are a little different, they changed a lot in IIS4.
0
 

Author Comment

by:waleed072098
ID: 1830903
hello,
Good morning

I checked the server it is IIS 3 ver 4.0.
0
 

Author Comment

by:waleed072098
ID: 1830904
what the difference b/w 3 & 4. You recommend upgrading ?
0
 

Author Comment

by:waleed072098
ID: 1830905
what the difference b/w 3 & 4. You recommend upgrading ?
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830906
Hi waleed,

I don't have IIS4, so I don't know. I have read one big thing is it makes it easy to run multiple virtual sites (all with separate domain names) on a single IP address. The configuration is much different, it got so big they moved much of it out of the registry into a separate "metabase", and you must configure it from their dialogs. They also changed how scripts are called in some cases.

Did changing back to %s %s and adding the Status: line make a difference?
0
 

Author Comment

by:waleed072098
ID: 1830907
I removed the %s %s and it wait until timeout


What is the ststus: ?

I put it back it displays the download window.

Now it is like this:
pl:REG_SZ : C:\perl\perl5\bin\perl.exe %s %s

and it
0
 

Author Comment

by:waleed072098
ID: 1830908
sorry there id a dot before pl
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830909
Well,
pl:REG_SZ : C:\perl\perl5\bin\perl.exe %s %s
should be
pl:REG_SZ : C:\perl\perl5\bin\perl.exe %s %s
(with a dot) but you said before that was just an error in cutting and pasting, it was there in the registry.

The Status I was referring to was my last suggestion yesterday -
 Let's try adding the %s %s back to the registry entry, then insert the following line into your test script at the top.

print "HTTP/1.0 200 OK\n";

It should make no difference, but...
0
 

Author Comment

by:waleed072098
ID: 1830910
I removed the %s %s and it wait until timeout


What is the ststus: ?

I put it back it displays the download window.

Now it is like this:
pl:REG_SZ : C:\perl\perl5\bin\perl.exe %s %s

and it
0
 

Author Comment

by:waleed072098
ID: 1830911
You know what happend ? strange

When I clicked on the cgi from the html, it opend the download window
I chose to dowanload  but it did not downlaod the content of th file test.pl but the result which is "It worked".

And that was even before the addition of this line  [print "HTTP/1.0 200 OK\n";  ]
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830912
This is what I had expected when you originally got the Save As box - it shows the script is running but the headers are wrong, so the browser doesn't know what to do with it. This is progress!

The headers in the test program I gave you should be enough, but maybe for some reason IIS wants a status header- so the [print "HTTP/1.0 200 OK\n";  ] should help. If it still doesn't work, copy and paste the test script here again.

Once that works it's on to your *real* script.
0
 

Author Comment

by:waleed072098
ID: 1830913
This is the script

#! /usr/local/bin/perl
print "HTTP/1.0 200 OK\n";
print "Content-Type:text/plain\n\nIt worked\n";

It still doing the same. I removed the first line and tried again. It still doing the same thing.

0
 

Author Comment

by:waleed072098
ID: 1830914
This is the script

#! /usr/local/bin/perl
print "HTTP/1.0 200 OK\n";
print "Content-Type:text/plain\n\nIt worked\n";

It still doing the same. I removed the first line and tried again. It still doing the same thing.

0
 

Author Comment

by:waleed072098
ID: 1830915
This is the script

#! /usr/local/bin/perl
print "HTTP/1.0 200 OK\n";
print "Content-Type:text/plain\n\nIt worked\n";

It still doing the same. I removed the first line and tried again. It still doing the same thing.

0
 
LVL 6

Expert Comment

by:alamo
ID: 1830916
There should be a space after the : before the t in the Content-type: text/plain line. Not sure if that will make a difference.

When the server doesn't recognize the Content-type, it might add one that causes the browser to open the Save box.
0
 

Author Comment

by:waleed072098
ID: 1830917
This is the script

#! /usr/local/bin/perl
print "HTTP/1.0 200 OK\n";
print "Content-Type:text/plain\n\nIt worked\n";

It still doing the same. I removed the first line and tried again. It still doing the same thing.

0
 

Author Comment

by:waleed072098
ID: 1830918
It tried id didn't work same as before. But I TRIED TO RUN IT USING NETSCAPE 4
and guess what it worked !

I tried to run my script using NETSCAPE 4 and it also worked.

What is wrong with Internet explorer (Navigator ver. 4) my friend ? It still open the save as window .
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830919
That's strange... text/plain should be a perfectly valid, Netscape loves it and IE accepts it when the file ends in .txt. I think this is a case of IE not paying complete attention to the MIME type and letting the file extension confuse it.

Sorry about that - I  thought the test script was so simple that it couldn't fail and it did anyway. Change the Content-type from text/plain to text/html and it will work. This will confirm that the server is set up properly.
0
 

Author Comment

by:waleed072098
ID: 1830920
Ok, I'll do that but tomorrow morning. It's time for class my friend. Thanks
0
 

Author Comment

by:waleed072098
ID: 1830921

Ok, it worked now in both (netscape + IE). I thank you very much.
I appreciat it.
0
 
LVL 6

Expert Comment

by:alamo
ID: 1830922
Great! Does your script from Unix work also?
0
 

Author Comment

by:waleed072098
ID: 1830923
yes. with yor help !
0
 
LVL 6

Accepted Solution

by:
alamo earned 50 total points
ID: 1830924
Well, then I'll post an answer to close this question out.

Glad I could help!
0
 

Author Comment

by:waleed072098
ID: 1830925

I wish I had more points. GOOD LUCK !
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to count occurrences of each item in an array.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now