Solved

Problem with Location header and shell script

Posted on 1998-08-07
3
185 Views
Last Modified: 2013-12-25
I have a problem executing a CGI program (in C) inside a script. The CGI writes a Location header. If the CGI is executed directly from a browser, it runs fine, but if the script is executed, the browser prints the location text in browser but not change the location.
I have cut the CGI and the script to the next:
Script (nph-script):
      #!/bin/sh
      exec /directory/prueba
CGI: The source code from prueba.c is:
      void main (void) { printf("Location: http://www.aranzadi.es\n\n");}

With these codes, if I put in browser the URL
       http://server/cgi/nph-script
the browser prints the location text (Location: http://www.aranzadi.es) instead change the location in the browser.

My server is Netscape Enterprise Server 2.01 under Solaris 2.51
I have a lot of scripts that call CGI's and all of them run fine, but this case fails. WHY????
0
Comment
Question by:carlos0007
[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
 

Accepted Solution

by:
bjornh earned 200 total points
ID: 1831417
Rename your script file to script.cgi. In this case your script should not begin with 'nph-'.

Bjorn
0
 

Author Comment

by:carlos0007
ID: 1831418
Thanks, Bjornh.

Now, the script runs fine.

Can you say me what's the meaning of the prefix 'nph-'?

Carlos.

0
 

Expert Comment

by:bjornh
ID: 1831419
When you use nph- a direct socket connection will be made between your server and your browser. Headers will not be processed by your webbrowser, but will be send to the browser without being processed. You can use it to 'push' information to the browser. Normally the html-page wont be displayed until all data is written to the page, when using nph- it is updated right away.

When you use nph- you also dont want to use Content-type: text/html, it will be printed in your browser, like the location text.

For more information make some searches on the internet with the keywords 'nph-', 'server push', 'html', '...'

Good luck!

Bjorn
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

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