473,385 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Perl script on IIS not executing

11
Hi,
I have configured IIS to run perl/cgi scripts the output is printed out in HTML but everytime I run the script the HTML is just outputting the code can someone tell me what I am doing wrong
Aug 7 '07 #1
4 1611
numberwhun
3,509 Expert Mod 2GB
That means that either your web server is not truly configured conrrectly to handle CGI or you are not putting your CGI script in the correct place. Unfortunately, I know nothing about IIS. But, a quick google search turned up this link to Micro$oft's TechNet. Hope that it helps.

Regards,

Jeff
Aug 7 '07 #2
markoj
11
Thanks Jeff,
I still have no luck with it I ran some test scripts that i got from net and they are working ok so I think my code may be a little out of shape could someone take a look and let me know what they think

Expand|Select|Wrap|Line Numbers
  1. #!/C:\Perl\bin
  2.  
  3. use warnings;
  4. use strict;
  5.  
  6. print <<HTTPHDR;
  7. Content-type: text/html
  8.  
  9. HTTPHDR
  10.  
  11. print <<HEADER;
  12. <HTML>
  13. <HEAD>
  14. <TITLE>NAS Disk</TITLE>
  15. </HEAD>
  16. HEADER
  17.  
  18. print <<OPENBODY;
  19. <BODY><H2>Nas Disk capacity</H2>
  20. <PRE>
  21. OPENBODY
  22.  
  23. # my $data_file = '/perly/nas01.txt';
  24. my $data_file = 'nas01.txt';
  25. open DATA, "$data_file" or die "can't open $data_file $!";
  26. my @read_data = <DATA>;
  27. my @array_of_data = map { SpecialChars($_); } @read_data;
  28. close DATA;
  29.  
  30. foreach my $line ( @array_of_data ) {
  31.     if ($line =~ m/levels/i) {
  32.         print "$line\n";
  33.  
  34.     } elsif ($line =~ m/date/i) {
  35.         print "$line\n";
  36.  
  37.     } elsif ($line =~ m/hostname/i) {
  38.         print "$line\n";
  39.  
  40.     } elsif ($line =~ m/uptime/i) {
  41.         print "$line\n";
  42.     }
  43. }
  44.  
  45. print "================================================== ==============================<br>\n";
  46.  
  47. foreach my $line ( @array_of_data ) {
  48.     if ($line =~ m/filesystem/i) {
  49.         print "$line\n";
  50.  
  51.     } elsif ($line =~ m/SQLsrv/i) {
  52.         print "$line\n";
  53.     }
  54. }
  55.  
  56. print "================================================== ==============================<br>\n";
  57. print "</PRE>\n";
  58.  
  59. print "<TABLE border=1>\n";
  60. my $lookdisk = 0;
  61. foreach my $lines ( @array_of_data ) {
  62.     if ($lines =~ m/(\d+)[%]/i) {
  63.         my $val = $1;
  64.         if ($val > 80) {
  65.             $lookdisk++;
  66.             print <<LOOKDISK;
  67. <TR style="color: red"><TD><PRE>$lines</PRE></TD><TH>Please look at this disk immediately.</TH></TR>
  68. LOOKDISK
  69.  
  70.         } else {
  71.             print <<OKDISK;
  72. <TR style="color: green"><TD><PRE>$lines</PRE></TD><TH>Disk levels are ok.</TH></TR>
  73. OKDISK
  74.         }
  75.     }
  76. }
  77.  
  78. if ($lookdisk == 0) {
  79.     print <<ALLDISKOK;
  80. <TR style="color: green"><TH colspan=2>Disk levels are ok.</TH></TR>
  81. ALLDISKOK
  82. }
  83. print "</TABLE>\n";
  84.  
  85. print <<HTMLFOOT;
  86. </BODY>
  87. </HTML>
  88. HTMLFOOT
  89.  
  90. # Remove special chars from input
  91. sub SpecialChars($) {
  92.     my ($line) = @_;
  93.     $line =~ s/&/&amp;/sg; # Correct special chars
  94.     $line =~ s/</&lt;/sg;
  95.     $line =~ s/>/&gt;/sg;
  96.     return($line);
  97. }
  98.  
Aug 8 '07 #3
miller
1,089 Expert 1GB
Look at your execute line. I guess that you probably one the following instead:

Expand|Select|Wrap|Line Numbers
  1. #!c:\perl\bin\perl.exe
  2.  
Whenever you're trying to simply get a script to work, always go back to "Hello World". It's the easiest way to isolate the problem to just your webserver itself, versus some possible combination of issues.

Expand|Select|Wrap|Line Numbers
  1. #!c:\perl\bin\perl.exe
  2.  
  3. print "Content-type: text/html\n\n";
  4.  
  5. print "Hello World\n";
  6.  
- Miller
Aug 8 '07 #4
markoj
11
Thanks Miller,
I started from top and went through code line by line and between the perl.exe line and the file the script was meant to be readin been in the wrong place problem is solved
Markoj
Aug 9 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Keith | last post by:
All: What is the difference between Perl (CGI) and PHP (Apache module)? I thought both used servers to direct the user to the appropiate Perl or PHP program in order to execute the program to...
0
by: SS | last post by:
I am trying to execute some python commands within a perl script and running into problems. The following works: python -c "import mypkg;do this; do that" however when I try to do something like...
3
by: PzYon | last post by:
Hey 2gether! I'm trying to execute a PERL script on the web server when the user presses a button in an ASP.NET Web Application using Visual Basic. The most obvious solution for me seemed to be...
3
by: Nathan Gilbert | last post by:
I am wanting to use javascript to select between different *.css files dependent on the user's browser. I am also wanting to generate the html document containing this javascript dynamically using...
20
by: Shawn Milo | last post by:
I'm new to Python and fairly experienced in Perl, although that experience is limited to the things I use daily. I wrote the same script in both Perl and Python, and the output is identical. The...
2
by: sunilsn | last post by:
Hi, I am newbie to perl, I hope you guys will help me resolve the challenge I am facing. I have a unix shell script on one UNIX machine say A, and a batch file on windows machine say B. Now I want...
1
by: idorjee | last post by:
hi all, i've been trying to write a perl cgi script to generate an html output of the blast (program) and it's parsed results on the browser. following are some of the few lines from the script. the...
1
by: Balajisanthanakrishnan | last post by:
Old Title: Hi all, need help for this perl script- thanks in advance I am BalajiSanthanakrishnan, chennai. Now I am working in a Perl Script which is executing in the Unix Servers. Basically i am...
2
by: prakashpb | last post by:
Hello All, I am new to perl. I have to write some code in perl on windows. I have to invoke/run a shell file sample.sh from within perl file. When the perl while is executing, it should run to...
3
by: tundal45 | last post by:
Hey Guys, I am trying to automate the process of loading data in our oracle server. As a part of that process, I am working on a perl script that loads external tables from data files. What I am...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.