Link to home
Start Free TrialLog in
Avatar of carlos0007
carlos0007Flag for Spain

asked on

Problem with Location header and shell script

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????
ASKER CERTIFIED SOLUTION
Avatar of bjornh
bjornh
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of carlos0007

ASKER

Thanks, Bjornh.

Now, the script runs fine.

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

Carlos.

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