Solved

Simple CGI Question

Posted on 1997-04-14
3
255 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
  • 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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.
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now