# Getting error

**URL:** <https://community.unix.com/t/getting-error/190830>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [March 28, 2008, 9:33pm UTC](https://community.unix.com/t/getting-error/190830 "2008-03-28T21:33:27Z")\
**Posts on this page:** 18\
**Page:** 2

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_22734026db12803ebb3e059622ac3534.png) [@era](https://community.unix.com/u/era)\
**Post date:** [March 29, 2008, 10:13am UTC](https://community.unix.com/t/getting-error/190830/21 "2008-03-29T10:13:29Z")

</div>

Try perl -c scriptname on the server.

---

<div class="post-metadata">

**Author:** ![marringi](https://community.unix.com/letter_avatar/marringi/32/6_22734026db12803ebb3e059622ac3534.png) [@marringi](https://community.unix.com/u/marringi)\
**Post date:** [March 29, 2008, 10:25am UTC](https://community.unix.com/t/getting-error/190830/22 "2008-03-29T10:25:24Z")

</div>

where do I do that?

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_22734026db12803ebb3e059622ac3534.png) [@era](https://community.unix.com/u/era)\
**Post date:** [March 29, 2008, 10:32am UTC](https://community.unix.com/t/getting-error/190830/23 "2008-03-29T10:32:39Z")

</div>

You need a shell account on the server.

This is getting slightly out of hand ...

---

<div class="post-metadata">

**Author:** ![marringi](https://community.unix.com/letter_avatar/marringi/32/6_22734026db12803ebb3e059622ac3534.png) [@marringi](https://community.unix.com/u/marringi)\
**Post date:** [March 29, 2008, 11:29am UTC](https://community.unix.com/t/getting-error/190830/24 "2008-03-29T11:29:43Z")

</div>

I got this to work:

> [@](#):
>
> #!/usr/local/bin/perl  
> #  
> # hello\_s.pl-- simple "hello, world" program to demonstrate basic  
> # CGI output.  
> #
> 
> # Print the CGI response header, required for all HTML output  
> # Note the extra \n, to send the blank line  
> print "Content-type: text/html\n\n" ;
> 
> # Print the HTML response page to STDOUT  
> print \<\<EOF ;  
> \<html\>  
> \<head\>\<title\>CGI Results\</title\>\</head\>  
> \<body\>  
> \<h1\>Hello, world.\</h1\>  
> \</body\>  
> \</html\>  
> EOF
> 
> exit ;

But when I add:

> [@](#):
>
> use CGI qw(:all);  
> use strict;
> 
> my $info;  
> my $response;
> 
> if($info = param("info")){  
> $response = '$info"';  
> } else {  
> $response = 'No result';  
> }

it shows the error:

> [@](#):
>
> Undefined subroutine &main::param called at test.cgi line 13.

So it must be the something wrong I'd think with

> [@](#):
>
> if($info = param("info")){

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_22734026db12803ebb3e059622ac3534.png) [@era](https://community.unix.com/u/era)\
**Post date:** [March 29, 2008, 11:38am UTC](https://community.unix.com/t/getting-error/190830/25 "2008-03-29T11:38:13Z")

</div>

The param() method is defined in the CGI library. You are not getting an error about CGI missing on your system before that? Also try use CGI qw/param/ just as a quick check.

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_22734026db12803ebb3e059622ac3534.png) [@era](https://community.unix.com/u/era)\
**Post date:** [March 29, 2008, 11:40am UTC](https://community.unix.com/t/getting-error/190830/26 "2008-03-29T11:40:40Z")

</div>

I was going to ask about the missing Content-Type header too. You might as well add that from the example code.

---

<div class="post-metadata">

**Author:** ![marringi](https://community.unix.com/letter_avatar/marringi/32/6_22734026db12803ebb3e059622ac3534.png) [@marringi](https://community.unix.com/u/marringi)\
**Post date:** [March 29, 2008, 11:52am UTC](https://community.unix.com/t/getting-error/190830/27 "2008-03-29T11:52:03Z")

</div>

Could we maybe go back a few steps.

Could you add a code to this script that gets the word from the location. Say the location is test.cgi?test=hello. THe script would fetch the word and put it into the script instead of the word "location".

> [@](#):
>
> #!/usr/local/bin/perl -s
> 
> use CGI::Carp qw/fatalsToBrowser/;  
> use strict;
> 
> print "Content-type: text/html\n\n" ;
> 
> print \<\<EOF ;  
> \<html\>  
> \<head\>\<title\>Test\</title\>\</head\>  
> \<body\>  
> \<h1\>Word from location\</h1\>  
> \</body\>  
> \</html\>  
> EOF
> 
> exit ;

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_22734026db12803ebb3e059622ac3534.png) [@era](https://community.unix.com/u/era)\
**Post date:** [March 29, 2008, 12:20pm UTC](https://community.unix.com/t/getting-error/190830/28 "2008-03-29T12:20:20Z")

</div>

param works with POST forms; to use GET, which encodes the parameter in the URI, use url\_param

You seem to have replaced "#!/usr/bin/perl -w" with "-s" at some point, apparently by mistake. I took out the -s and added use warnings instead.

Other than that, I added a use CGI qw/url\_param/ and the call to url\_param, and put it in $location, so the template now says "Word from $location".

```nohighlight
#!/usr/local/bin/perl

use CGI qw/url_param/;
use CGI::Carp qw/fatalsToBrowser/;
use strict;
use warnings;

my $location=url_param("test");

print "Content-type: text/html\n\n" ;

print <<EOF ;
<html>
<head><title>Test</title></head>
<body>
<h1>Word from $location</h1>
</body>
</html>
EOF

exit ;

```

---

<div class="post-metadata">

**Author:** ![marringi](https://community.unix.com/letter_avatar/marringi/32/6_22734026db12803ebb3e059622ac3534.png) [@marringi](https://community.unix.com/u/marringi)\
**Post date:** [March 29, 2008, 12:39pm UTC](https://community.unix.com/t/getting-error/190830/29 "2008-03-29T12:39:19Z")

</div>

Thanks, that worked grate!

But when I put in

> [@](#):
>
> \<!--#include virtual="index.cgi?i=db&search=$location" --\>

it only shows in the page source. Do I have to do something special to have the script include information?

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_22734026db12803ebb3e059622ac3534.png) [@era](https://community.unix.com/u/era)\
**Post date:** [March 29, 2008, 2:11pm UTC](https://community.unix.com/t/getting-error/190830/30 "2008-03-29T14:11:22Z")

</div>

That's a server-side include, the server should be configured to expand that for you.

---

<div class="post-metadata">

**Author:** ![marringi](https://community.unix.com/letter_avatar/marringi/32/6_22734026db12803ebb3e059622ac3534.png) [@marringi](https://community.unix.com/u/marringi)\
**Post date:** [March 29, 2008, 2:17pm UTC](https://community.unix.com/t/getting-error/190830/31 "2008-03-29T14:17:31Z")

</div>

i.c..  
Do I have to get the hosting company to do that for me?

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_22734026db12803ebb3e059622ac3534.png) [@era](https://community.unix.com/u/era)\
**Post date:** [March 29, 2008, 3:01pm UTC](https://community.unix.com/t/getting-error/190830/32 "2008-03-29T15:01:01Z")

</div>

Probably. I was sort of under the impression that the script you started out with was somehow working already, and you wanted to change it.

---

<div class="post-metadata">

**Author:** ![marringi](https://community.unix.com/letter_avatar/marringi/32/6_22734026db12803ebb3e059622ac3534.png) [@marringi](https://community.unix.com/u/marringi)\
**Post date:** [March 29, 2008, 4:02pm UTC](https://community.unix.com/t/getting-error/190830/33 "2008-03-29T16:02:01Z")

</div>

No, but the script you created for me does what I want it to do. But the \<!--#include virtual--\> only loads in the pages source. I got this reply when I asked my host to help me with server-side include (I showed them the script and told them what I intended to do):

> [@](#):
>
> We have Installed perl module CGI::Carp on the server. Now you can use the script.

Still it will not load the SSI. Was this not what I needed to get this to work?

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_22734026db12803ebb3e059622ac3534.png) [@era](https://community.unix.com/u/era)\
**Post date:** [March 29, 2008, 4:04pm UTC](https://community.unix.com/t/getting-error/190830/34 "2008-03-29T16:04:39Z")

</div>

Nope, SSI is unrelated to anything Perl. They might not even be offering it for all I know. Ask.

Here's Dreamhost's SSI page, for example: ["SSI: Server-Side Includes" - DreamHost Knowledge Base](http://blog.dreamhosters.com/kbase/index.cgi?area=2502)

You're probably not on Dreamhost (and some of the stuff there does not apply at other providers), but look for something similar on your provider's pages.

Using a CGI to conditionally serve up another CGI via SSI seems slightly odd, but what do I know, I'm no web jockey.

---

<div class="post-metadata">

**Author:** ![marringi](https://community.unix.com/letter_avatar/marringi/32/6_22734026db12803ebb3e059622ac3534.png) [@marringi](https://community.unix.com/u/marringi)\
**Post date:** [March 29, 2008, 6:27pm UTC](https://community.unix.com/t/getting-error/190830/35 "2008-03-29T18:27:13Z")

</div>

> [@](#):
>
> That's a server-side include, the server should be configured to expand that for you.  
> Reply With Quote

If I had a Shell account, would this be something I could do myself?

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_22734026db12803ebb3e059622ac3534.png) [@era](https://community.unix.com/u/era)\
**Post date:** [March 29, 2008, 6:36pm UTC](https://community.unix.com/t/getting-error/190830/36 "2008-03-29T18:36:30Z")

</div>

Web hosting firms typically like to manage that sort of thing centrally; if they offer it then it's sure to be mentioned in their advertising (possibly with an extra price tag). I don't think a shell account would help at all, but again, check with your hosting provider.

---

<div class="post-metadata">

**Author:** ![marringi](https://community.unix.com/letter_avatar/marringi/32/6_22734026db12803ebb3e059622ac3534.png) [@marringi](https://community.unix.com/u/marringi)\
**Post date:** [March 29, 2008, 7:06pm UTC](https://community.unix.com/t/getting-error/190830/37 "2008-03-29T19:06:27Z")

</div>

ok, i.c.

What should I be looking for in an ad to know that a company provides this?

The Support center where I host asked:

> [@](#):
>
> Please let us know what are the server side requirement for the SSI.

Any idea what I should tell them?

---

<div class="post-metadata">

**Author:** ![era](https://community.unix.com/letter_avatar/era/32/6_22734026db12803ebb3e059622ac3534.png) [@era](https://community.unix.com/u/era)\
**Post date:** [March 30, 2008, 4:06am UTC](https://community.unix.com/t/getting-error/190830/38 "2008-03-30T04:06:46Z")

</div>

Good question. You could say you want what Dreamhost offers and see how they react. Sounds like a small shop who might be willing to tweak their system in order to keep you as a customer. Also sounds like they don't have any SSI facility at all at the moment, otherwise they'd just point you to its documentation.

This is all a bit mysterious; I have a nagging doubt that you will tell us in the end that the reason you want this for i X and we'd all jump and shout and point you to the web site where you can get that.

[Previous page](https://community.unix.com/t/getting-error/190830.md?page=1)
