Solved

Simple CGI Question

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create associate webpages / websites 3 67
Coldfusion- Create and save form elements in Database 7 61
cookies analysis tools 2 72
Installing Git and chefdk via bat script 8 60
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

920 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

16 Experts available now in Live!

Get 1:1 Help Now