| Author |
cgi script to capture http headers
|
|
| Kaushal Shriyan 2006-09-28, 7:55 am |
| Hi ALL
I have a issue
when i use script (test.cgi)
#!/bin/bash
echo "Content-type: text/plain";
echo
set
I get all the http headers populated with the values correctly
but when I use the below script (test-cgi)
#!/bin/sh
# disable filename globbing
set -f
echo Content-type: text/plain
echo
echo CGI/1.0 test script report:
echo
echo argc is $#. argv is "$*".
echo
echo SERVER_SOFTWARE = $SERVER_SOFTWARE
echo SERVER_NAME = $SERVER_NAME
echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
echo SERVER_PROTOCOL = $SERVER_PROTOCOL
echo SERVER_PORT = $SERVER_PORT
echo REQUEST_METHOD = $REQUEST_METHOD
echo HTTP_ACCEPT = "$HTTP_ACCEPT"
echo PATH_INFO = "$PATH_INFO"
echo PATH_TRANSLATED = "$PATH_TRANSLATED"
echo SCRIPT_NAME = "$SCRIPT_NAME"
echo QUERY_STRING = "$QUERY_STRING"
echo REMOTE_HOST = $REMOTE_HOST
echo REMOTE_ADDR = $REMOTE_ADDR
echo REMOTE_USER = $REMOTE_USER
echo AUTH_TYPE = $AUTH_TYPE
echo CONTENT_TYPE = $CONTENT_TYPE
echo CONTENT_LENGTH = $CONTENT_LENGTH
I dont get values for REMOTE_HOST = and REMOTE_USER =
I am calling the script http://mydomain.com/cgi-bin/test-cgi
Please let me know if you need any information
Thanks and Regards
Kaushal
| |
| Beginner 2006-09-28, 7:55 am |
| Hi
On 28 Sep 2006 at 17:21, Kaushal Shriyan wrote:
> Hi ALL
>
> I have a issue
>
> when i use script (test.cgi)
>
> #!/bin/bash
> echo "Content-type: text/plain";
> echo
> set
>
> I get all the http headers populated with the values correctly
>
> but when I use the below script (test-cgi)
>
> #!/bin/sh
>
> # disable filename globbing
> set -f
> I dont get values for REMOTE_HOST = and REMOTE_USER =
>
> I am calling the script http://mydomain.com/cgi-bin/test-cgi
>
> Please let me know if you need any information
>
> Thanks and Regards
>
> Kaushal
I think the first point is that your not using Perl !!! This is a
list 4 perl not shell scripting.
Secondly remote_user is not always avaiable.
Lastly you could try:
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw/:standard/;
my $q = new CGI;
print $q->header(-type=>'text/html');
print $q->start_html('test');
print remote_host();
print $q->end_html;
After that I would tenatively suggest doing some basic reading on the
subject (CGI and/or Perl/CGI).
Good luck.
| |
| praveen.batchu@gmail.com 2006-09-29, 3:55 am |
| First thing is that you didn't linked to perl in the script.
U are linking to shell.
Change the she-bang line in the starting.
Try to use CGI module with headers. View CGI tutorials in the web.
I can give you the code. But if you study it and use then you will get
more info.
I know very less I think.
If not found then I will post the code here.
Kaushal Shriyan wrote:
> Hi ALL
>
> I have a issue
>
> when i use script (test.cgi)
>
> #!/bin/bash
> echo "Content-type: text/plain";
> echo
> set
>
> I get all the http headers populated with the values correctly
>
> but when I use the below script (test-cgi)
>
> #!/bin/sh
>
> # disable filename globbing
> set -f
>
> echo Content-type: text/plain
> echo
>
> echo CGI/1.0 test script report:
> echo
>
> echo argc is $#. argv is "$*".
> echo
>
> echo SERVER_SOFTWARE = $SERVER_SOFTWARE
> echo SERVER_NAME = $SERVER_NAME
> echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
> echo SERVER_PROTOCOL = $SERVER_PROTOCOL
> echo SERVER_PORT = $SERVER_PORT
> echo REQUEST_METHOD = $REQUEST_METHOD
> echo HTTP_ACCEPT = "$HTTP_ACCEPT"
> echo PATH_INFO = "$PATH_INFO"
> echo PATH_TRANSLATED = "$PATH_TRANSLATED"
> echo SCRIPT_NAME = "$SCRIPT_NAME"
> echo QUERY_STRING = "$QUERY_STRING"
> echo REMOTE_HOST = $REMOTE_HOST
> echo REMOTE_ADDR = $REMOTE_ADDR
> echo REMOTE_USER = $REMOTE_USER
> echo AUTH_TYPE = $AUTH_TYPE
> echo CONTENT_TYPE = $CONTENT_TYPE
> echo CONTENT_LENGTH = $CONTENT_LENGTH
>
> I dont get values for REMOTE_HOST = and REMOTE_USER =
>
> I am calling the script http://mydomain.com/cgi-bin/test-cgi
>
> Please let me know if you need any information
>
> Thanks and Regards
>
> Kaushal
| |
| Kenneth Tomiak 2006-10-05, 6:56 pm |
| You are not the first to want fields that are not supported by every browser
nor every server. If you are not getting values it is because the fields are
not there. I have seen them in all upper case, case sensitive, or not at
all. So again, if they aren't there you need to join the ranks of people who
believe they have to be there and write your own server and browser and then
force everybody to use them. Until then, you can only use what the software
supports.
<praveen.batchu@gmail.com> wrote in message
news:1159514150.125472.118300@e3g2000cwe.googlegroups.com...
> First thing is that you didn't linked to perl in the script.
> U are linking to shell.
> Change the she-bang line in the starting.
> Try to use CGI module with headers. View CGI tutorials in the web.
> I can give you the code. But if you study it and use then you will get
> more info.
> I know very less I think.
> If not found then I will post the code here.
>
> Kaushal Shriyan wrote:
>
|
|
|
|