Solved

Can Server side executables by Unix/Linux Scritps?

Posted on 1998-09-16
3
148 Views
Last Modified: 2013-12-25
I'm new to programming for the web, but not to unix.  My question is:  Can I delploy a server side executable that is just a list of unix commands (like a batch file) that users can hit from their browser?

I want a Web address that points to a server side executable  that sends some mail, then outputs some html in finishing.  What I've currently got in this script is:

mail -s "a subject" anaddress@anywhere.com < MailMessage.txt
cat testpage.html

When I run this from the telnet prompt it sends the mail and outputs the correct html.  When I hit it from my browser it gives my an internal server error.  Bummer ;-(

What am I doing wrong?  Can U use a Unix script for server side processing?  How do I get the browser to tell the server to execute my script rather than display it?

PS:  I've already chmod'ed it to 755, so it is executable.

Thanx in advance,
 
0
Comment
Question by:KirkGray
[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 7

Accepted Solution

by:
faster earned 200 total points
ID: 1828679
Put these in front of your script:

echo "Content-type: text/html\n\n"
0
 
LVL 7

Expert Comment

by:faster
ID: 1828680
A server side executable is just a CGI.  It can be anything, including shell  script.  The standout will be redirected to the browser.  However, there is onething you need to take care of:  The output can not be a simple html file, it has to conform to the HTTP standard.  In short, you need to output some "response header" before the response body (html, for example).  The header takes the form: name1: value1\nname2: value2\n...\n.  An empty line is to indicate the end of the header.  Content-type is the most common header you will need.

Please also note that besides writing the CGI script, you may also need to do some config on the web server so that it know it is a CGI, bot a normal html file.  The exact config depends on the server.  In most cases, you need to set a directory to be "CGI directory" or set the file extension to be recognized as CGI.  Check this with your web master.
0
 

Author Comment

by:KirkGray
ID: 1828681
Thanx man, the points are all yours!
0

Featured Post

Interactive Way of Training for the AWS CSA Exam

An interactive way of learning that will help you visualize core concepts so that you can be more effective when taking your AWS certification exam.  Built for students by a student to help them understand the concepts that they are being taught.

Question has a verified solution.

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

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

630 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