Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PERL - #exec inside an HTML document

Posted on 2003-03-27
11
Medium Priority
?
359 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
  • 5
  • 3
9 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Industry Leaders: 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!

Question has a verified solution.

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

JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

564 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