?
Solved

PERL - #exec inside an HTML document

Posted on 2003-03-27
11
Medium Priority
?
349 Views
Last Modified: 2013-12-25
I was just wondering if anyone knows why the following code doesn't work when included in an html file using:
   <!--#exec cmd="../cgi-bin/test.cgi"-->

The output is:
--------------
Test

Test2




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

It seems like it doesn't like me trying to print the array or the foreach loop.  Anyone have info on this?  It's not a big deal cause i can just stick the HTML in the Perl script, but i'm a neat freak and if i could just include the script, it'd make it look nicer.

Thanks,
Eric


Here's the test.cgi file:
-------------------------
#!/usr/bin/perl
use Text::ParseWords;

open(csvDB, "test.csv");

print "test<br><br>\n\n";

@text=<csvDB>;

print "test2<br><br>\n\n";

print "@text<br><br>\n\n";

foreach $string (@text)
{
     chomp(@text);

     # for finding triple quotes
     $string =~ s/\"\"\"/\"\|/g;

     # for finding double quotes
     $string =~ s/\"\"/\|/g;

     print "$string<br>\n";

     @tokens = quotewords(",",0,$string);

     foreach $tok (@tokens)
     {
          # replace the pipes with quotes
          $tok =~ s/\|/\"/g;

          #print "$tok<br>\n";
     }
}

close (csvDB);

print "\n\n";


And if you're extra curious...
here's the test.csv file:
-------------------------
Make,Model,Year,Mileage,Price,Promotion,imgSrc
Ford,Mustang,1967,"8,000","25,000",,ford/67mustang.jpg
Ford,Focus,2000,"4,000","13,000",promo1,ford/00focus.jpg
Ford,Explorer,2003,900,"20,000",,ford/03explorer.jpg
0
Comment
Question by:Rico_plus_plus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
11 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 8223614
the posted test.cgi never printed what you declared as "output" (except you have replaced some basic perl functions)

Could you please verify ...
0
 
LVL 17

Expert Comment

by:dorward
ID: 8224209
Does:
  <!--#exec cmd="../cgi-bin/test.cgi"-->

Appear in the source code of the version of the file retrieved from the webserver? If so SSI is not enabled (either for the file extension you are using, or at all) and you should consult the manual for your webserver to find out how to turn it on.
0
 

Author Comment

by:Rico_plus_plus
ID: 8224605
<!--#exec cmd="../cgi-bin/test.cgi"--> doesn't appear in the source.  when i include it the program will replace it with everything between the '----'

--------------
test<br><br>

test2<br><br>

<br><br>




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

<a href="http://www.carsmartonline.com" target="_blank">see it here</a>
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Rico_plus_plus
ID: 8224616
i'm sorry... it's actually here:  http://www.carsmartonline.com/index2.html
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 8224909
ypur posted script works for me
just a type, probably:
   chomp(@text);
did you mean?
   chomp($string);

do you run the script on M$, or did you develop on M$ and run under *nix?
0
 

Author Comment

by:Rico_plus_plus
ID: 8226627
the output should be:
-------------
test<br><br>

test2<br><br>

Make,Model,Year,Mileage,Price,Promotion,imgSrc
 Ford,Mustang,1967,"8,000","25,000",,ford/67mustang.jpg
 Ford,Focus,2000,"4,000","13,000",promo1,ford/00focus.jpg
 Ford,Explorer,2003,900,"20,000",,ford/03explorer.jpg
<br><br>

Make,Model,Year,Mileage,Price,Promotion,imgSrc<br>
Ford,Mustang,1967,"8,000","25,000",,ford/67mustang.jpg<br>
Ford,Focus,2000,"4,000","13,000",promo1,ford/00focus.jpg<br>
Ford,Explorer,2003,900,"20,000",,ford/03explorer.jpg<br>

---------

is this what you got?

if i run it from the command line it works fine, but not when i include it in an HTML document.

i wrote it in notepad, but i'm running it on a linux machine running apache.

p.s. thanks for the chomp() suggestion
0
 

Author Comment

by:Rico_plus_plus
ID: 8229760
hey thanks for you help, but i've decided to forget about this whole thing and learn MySQL.  It's probably more beneficial and easier to use for what i want to do anyway.

thanks again,
eric
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 80 total points
ID: 8230857

yes it produced the output as you described.
did you edit the script with notepad? then you need to remove the returns after copying it to the Linux box
0
 

Author Comment

by:Rico_plus_plus
ID: 8230910
well...  i took your advice and removed the returns and tried again.  it still didn't give me the full output.  so i deleted it and totally retyped it in pico on the machine itself.  again, it didn't show the full output.  so i don't know what the deal with this thing is.  but like i said i'm gonna go with MySQL anyway so it's not a big deal.  I'm gonna leave the question open til the end of the month to see if any other solutions pop up, and if not i'll just give you the points hoffman.  i really appreciate your help.

thanks,
eric
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

764 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