Solved

Simple CGI Question

Posted on 1997-04-14
3
266 Views
Last Modified: 2013-12-25
I'm guessing this one isn't tough.  I'm going though a book on CGI, and I typed in my script, and put it in the cgi-bin on our server, and set the permissions properly, except it only sort of works.  I keep getting an error:

...ourserver/cgi-bin/pinglaura.cgi: echo: not found

Here's the script, which I've triple-checked for errors (yes, you may recognize it from Laura Lemay's book on HTML):
#!/bin/sh
echo "Content-type: text/html"
echo
echo "<HTML><HEAD>"
echo "<TITLE>Is Laura There?</TITLE>"
echo"</HEAD><BODY>"

ison='who | grep lemay'

if [ ! -z "$ison" ]; then
      echo "<P>Laura is logged in"
else
      echo "<P>Laura isn't logged in"
fi

echo "</BODY></HTML>"

The book says something about leaving a blank line after the header, but I'm not sure what that is in a CGI script.  The HTML is really just an HREF to this script.  I'm running on a Windows NT box.  Can anyone help?  Is it because that opening line (#!/bin/sh) is UNIX?

Thanks,

Dave.
0
Comment
Question by:Raydot
[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
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
julio011597 earned 50 total points
ID: 1827898
It seems that your cgi cannot find the 'echo' command.
This should be a PATH problem.
You could ask your sys admin which is the full path to the echo command, then add a line to your script this way:

(say, echo is in /usr/bin)

--//--
#!/bin/sh
PATH=$PATH:/usr/bin #<-- line to add
...
--//--

If this does not work either, it's a permission problem, i.e. the web server user (usually 'nobody') cannot access the echo comand at all.
Again, ask your sys admin to set up the appropriate permissions.

HTH, julio
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1827899
SORRY, i didn't notice that: run and reject my answer!

Of course that won't work, since that IS a Unix shell script!
It CANNOT run on an NT box.

I'm afraid you won't be able to test any samples in your book.

Cheers, julio
0
 
LVL 3

Author Comment

by:Raydot
ID: 1827900
Yeah, it was simpler than I thought!  One check with our Web Guru and he told me that he hasn't EVER had luck doing what I'm trying to do.  So, we came up with the idea (with the generous help of the PERL mailing list) to just Telnet straight into the UNIX servers, and I'll just write the scripts straight in the language in which they were meant to be written.  Thanks julio.
0

Featured Post

Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

695 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