Solved

Problem with Location header and shell script

Posted on 1998-08-07
3
170 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
  • 2
3 Comments
 

Accepted Solution

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

Bjorn
0
 

Author Comment

by:carlos0007
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
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.
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.
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)

762 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

7 Experts available now in Live!

Get 1:1 Help Now