Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

QUERY_STRING has everything to the right of ? - What variable holds everything to the left? 1

Status
Not open for further replies.

southbeach

Programmer
Jan 22, 2008
879
US
Like my subject says:

QUERY_STRING has everything to the right of ? - What variable holds everything to the left?

When running cgi scripts (shell scripts using LINUX ksh), I can parse through QUERY_STRING to get the info submitted but I need to know which is the calling URL.

I need to get a hold of everything to the left of the ?

How do I go about this?

Thank you all in advance!




--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
Hi

There is no such thing like "everything on the left" from the web server's point of view, as the user agent does not send the URL as you write it in the browserș address bar ( or anywhere else ).

For example this thread's URL is

[tt][highlight #fcc]http[/highlight]://[highlight #cfc]tek-tips.com[/highlight][highlight #ccf]/viewthread.cfm?qid=1713892[/highlight]#newpost[/tt]

But the request to the server looks like this :
Code:
GET [highlight #ccf]/viewthread.cfm?qid=1713892[/highlight] [highlight #fcc]HTTP[/highlight]/1.1
Host: [highlight #cfc]tek-tips.com[/highlight]

So you will have to put together the URL from pieces :
Code:
url="[highlight #fcc]http${HTTPS:+s}[/highlight]://[highlight #cfc]$HTTP_HOST[/highlight][highlight #ccf]$REQUEST_URI[/highlight]"

But before writing CGI shell script better make sure you are an ace in shell scripting. No kidding. A poorly written shell script can be a huge security risk.
If you are not an ace, better use Perl with the [tt]CGI[/tt] module, which handles the necessary parsing and escaping.


Feherke.
feherke.github.io
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top