Hi Rick, et al: > On Fri, 28 Nov 2003, Louis wrote: > >> My objective is to get a Perl command line script get this for a domain. >> That's why I was trying some Net modules. Via browser the script gets it >> easy from the ENV%. > > You are referring to %ENV, I presume. > > The environment inside the web server is the CGI environment, > which is *VERY* different from the environment in the shell. > > In the shell, type: > > set > > The above will list all of the available env variables. > Perhaps you can pick on from the list variables that gives you > the hostname that you want.
[Louis] Had a look on my Red Hat Linux machine. "HOSTNAME" shows what I want, and appears the same to what CGI shows without "www". But then I need to pipe the output of this "set" for a script to read and get "HOSTNAME" . [Louis] I just tried set on another machine and "HOSTNAME" is different to what CGI says. > > Also: write a script for your web server to dump the CGI environment > to the browser. You will note that the environment is COMPLETELY > different from the shell. [Louis] Yes I already have that. [Louis] I think to make sure I get what I want I will use LWP to call a CGI script that dumps %ENV using my command line script. [Louis] Then the command line script just looks for HTTP_HOST 's data. A bit lengthy for trying to get a domain name using scripts running via command line. > > You refer to a script running in the browser. This is not what is > happening. The scripts you write run on the server, and the script > returns CONTENT to the browser. [Louis] Yes I know. Forgive my explanation on this. Thanks for the url. > > Perhaps a visit to http://hotwired.lycos.com/webmonkey/ will clear > up any misunderstandings you might have with web serving, the web > client-server model and CGI scripting. > > Good luck! > > > cheers > rickw > > P.S. here is a really simple script in perl that will dump the CGI > environment > to the web browser: > > print "Content-type: text/plain\r\n\r\n" > .join("\n",map {"$_=$ENV{$_}"} sort keys %ENV) > ."\n"; > > > > --------------------------------------------- > Rick Welykochy || Praxis Services Pty Limited > > "To mess up a Linux box, you need to work at it; > to mess up your Windows box, you just need to work on it." > -- Scott Granneman, SecurityFocus > -- I'm always learning something new everyday. Thanks Sluggers. -- SLUG - Sydney Linux User's Group - http://slug.org.au/ More Info: http://lists.slug.org.au/listinfo/slug
