?
Solved

Simple CGI Question

Posted on 1997-04-14
3
Medium Priority
?
269 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 100 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
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.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

752 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