Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Think about Loose Coupling
 
PerlMonks  

OT: would this ENV setup make you blow your lid too?

by leocharre (Priest)
on Jun 07, 2006 at 23:31 UTC ( [id://554207]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

leocharre has asked for the wisdom of the Perl Monks concerning the following question:

I am going insane.

We develop web stuff. Amongst other things, we develop sites for clients.

I work in a joint with my main man who I have a lot of respect for. He's a highly technical chap with hardware, with networks, with some obscure technologies. His main thing is not coding though. That's my side of things lately.

We have a 'special deal' with one of his buddies to host on this this server. His buddy is great and all. But I am about to put a **#( in something right about now.

Check this out.

One of my minor tasks today is setting up a client with a gallery, one that lets them change images, automatically makes thumbs.. etc. Should take me 15 minutes.

I do everything via the shell and vim.
My script had some troubles. So I figured one of the things I would do is spit out the ENV variables just to see what's up. Oops... no access to the error_logs via shell. No problem. Spit directly to screen.

What's this?,I ask..
This is what the server ENV is set to:

$VAR1 = { 'ZEN_WANT_DOS' => 'NO', 'SSH2_SFTP_LOG_FACILITY' => '-1', '_' => '/usr/bin/perl', 'LS_COLORS' => 'no=00:fi=01;30:di=01;36:ln=00;35:pi=40;33:so +=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=00;36:*.tar=00;37:*.tgz +=00;37:*.arj=00;37:*.taz=00;37:*.lzh=00;37:*.zip=00;37:*.z=00;37:*.Z= +00;37:*.gz=00;37:*.jpg=01;32:*.gif=01;32:*.bmp=01;32:*.ppm=01;32:*.tg +a=01;32:*.xbm=01;32:*.xpm=01;32:*.tif=01;32:*.mpg=01;32:*.avi=01;32:* +.gl=01;32:*.dl=01;32:', 'ZEN_VERSION' => '0.1', 'SHLVL' => '1', 'HISTSIZE' => '1000', 'PWD' => '/home/xxxxx/public_html/cgi-bin', 'SSH2_CLIENT' => 'xxxx.xxxx.xxx.xxx xxxx xxx.xxx.xxx.xxx xx' +, 'INPUTRC' => '/etc/inputrc', 'HOSTNAME' => 'xxx.xxx.xxx', 'LESSOPEN' => '|/usr/bin/lesspipe.sh %s', 'PS1' => '\\[\\][\\[\\]\\u\\[\\]@\\[\\]\\h \\[\\]\\W\\[\\]]\ +\[\\]\\$\\[\\] ', 'ZEN_WANT_COLOR' => 'yes', 'USER' => 'xxx', 'HOME' => '/home/xxx', 'OLDPWD' => '/home/xxx/public_html', 'ZEN_WHAT_SCHEME' => 'ice', 'TERM' => 'xterm', 'C1' => '', 'LOGNAME' => 'xxx', 'C2' => '', 'PATH' => '/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin', 'ZEN_WHAT_PROMPT' => 'linux', 'C3' => '', 'SHELL' => '/bin/bash', 'C4' => '', 'C5' => '', 'MAIL' => '/var/spool/mail/xxx', 'LANG' => 'en_US.iso885915' };

This is no major problem in itself. I can ask the sysadmin to give me something more normal. Thing is.. I am fuming - This is not normal. This is bs. Why do I have to waste my #21^#-!! time with this - I am tearing my hair out. I have never seen such a bogus ENV. This is no normal server.

I am about to go apes**t. Should I - or am I over reacting?

This dude has this server all messed up, and I'm getting tired of finding weird out of the norm stuff here. I am being almost forced to use it because the person I work for wants to give the business to his friend. A little nepotism is all good, but this is interfering with my work.

I've found sh#@$T^ like this before, the first thing I noticed was that use strict; was missing. It makes my insides burn. I would normally switch to another server/provider in two secs. But .. I am being told over and over again.. "it's nothing, we'll just ask my friend to set it up the way you want it.. "

And I keep getting these little surprises... Oh god please someone tell me I am not being insane and you would too lose it..

I am feeling really awkward about insisting on switching servers/providers for fear of violating nepotism, also, I really have a ton of respect for the people I work with. On the other hand I am thinking this is more harm then good - working with this kind of setup. Who knows what else there is wrong with these machines? Should I suck it up?

I was being a total retard. cees is a genius, I should be taken out back around the building and shot.
I was running this via the term without mimmicking a web environment. Wow. Wow. I'm so embarrassed, where did life go wrong. Why are there such low moments. Mea culpa. I'm sorry, I think I gotta stop working at night.

Replies are listed 'Best First'.
Re: OT: would this ENV setup make you blow your lid too?
by gellyfish (Monsignor) on Jun 08, 2006 at 07:15 UTC

    Er, after you calm down maybe you can explain how you output this environment? There seems to be an implication that this comes from a web application, however this looks very much like the kind of environment that you would find in an interactive shell on Linux for instance, and taken in that context this seems quite restrained - I appear to have twice as much stuff in %ENV.

    /j\

      use Data::Dumper; print STDERR Dumper (\%ENV);
Re: OT: would this ENV setup make you blow your lid too?
by xorl (Deacon) on Jun 08, 2006 at 09:14 UTC
    Doesn't look too different from mine:
    NETHACKOPTIONS=!autopickup,!mail,showexp,showscore,number_pad:1,hilite +_pet SSH_AGENT_PID=4203 HOSTNAME=xorl.intranet TERM=xterm SHELL=/bin/bash HISTSIZE=5000 GTK_RC_FILES=/etc/gtk/gtkrc:/home/xorl/.gtkrc-1.2-gnome2 WINDOWID=35682814 OLDPWD=/tmp/liberty QTDIR=/usr/lib/qt-3.1 USER=xorl LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01: +cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe= +00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.ta +r=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:* +.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm +=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:* +.xpm=00;35:*.png=00;35:*.tif=00;35: SSH_AUTH_SOCK=/tmp/ssh-XXGtnSON/agent.4151 SESSION_MANAGER=local/xorl.intranet:/tmp/.ICE-unix/4151 PATH=/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/ho +me/xorl/bin MAIL=/var/spool/mail/xorl PWD=/tmp INPUTRC=/etc/inputrc XMODIFIERS=@im=none EDITOR=/usr/bin/xemacs LANG=en_US.UTF-8 GDMSESSION=Default SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass SHLVL=2 HOME=/home/xorl GNOME_DESKTOP_SESSION_ID=Default LOGNAME=xorl LESSOPEN=|/usr/bin/lesspipe.sh %s VALGAAV=xxx.xxx.xxx.xxx DISPLAY=:0.0 G_BROKEN_FILENAMES=1 COLORTERM=gnome-terminal XAUTHORITY=/home/xorl/.Xauthority _=/usr/bin/env
    Could you elaborate as to why you think something is wrong?

      These cgi env variables are more common. Yours lacks QUERY_STRING and DOCUMENT_ROOT.

      The problem with stuff like this is developing small apps/scripts that are intended to run on multiple machines. This is why some standards are important. At least in regards to devel.

        Your node here implies you're running env dump from the command line, you're not going to see any cgi env variables from the command line.

        -derby
        You'll only get stuff like that if you have the webserver run it. Your post seemed to imply that you ran it from the command line which shouldn't have stuff like QUERY_STRING. I put the following script in my cgi-bin directory on my webserver:
        #!/usr/bin/perl print("Content-type: text/html\n\n"); foreach (keys %ENV) { print $_ . "==>" . $ENV{$_} . "<BR>"; }
        I then pointed my brower to the URL and here's the output:
        SCRIPT_NAME==>/~xorl/cgi-bin/test.pl SERVER_NAME==>devel.intranet SERVER_ADMIN==>xorl@mydomain.org.net.com HTTP_ACCEPT_ENCODING==>gzip,deflate HTTP_CONNECTION==>keep-alive REQUEST_METHOD==>GET HTTP_ACCEPT==>text/xml,application/xml,application/xhtml+xml,text/html +;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 SCRIPT_FILENAME==>/export/home/xorl/public_html/cgi-bin/test.pl SERVER_SOFTWARE==>Apache/2.0.52 (Red Hat) HTTP_ACCEPT_CHARSET==>ISO-8859-1,utf-8;q=0.7,*;q=0.7 QUERY_STRING==> REMOTE_PORT==>41051 HTTP_USER_AGENT==>Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) G +ecko/20060413 Red Hat/1.7.13-1.4.1 SERVER_PORT==>80 SERVER_SIGNATURE==> Apache/2.0.52 (Red Hat) Server at uit183.ntdp.intranet Port 80 HTTP_ACCEPT_LANGUAGE==>en-us,en;q=0.5 HTTP_COOKIE==>TZ=America%2FChicago; session_id=2d7fb6ee9da78c293d33620 +0de6f0219; authusername7=admin; authpassword7=06aed384ecae502cac7ae47 +c7597ffe6 REMOTE_ADDR==>10.33.1.32 HTTP_KEEP_ALIVE==>300 SERVER_PROTOCOL==>HTTP/1.1 PATH==>/usr/local/bin:/usr/bin:/bin REQUEST_URI==>/~xorl/cgi-bin/test.pl GATEWAY_INTERFACE==>CGI/1.1 SERVER_ADDR==>10.33.1.32 DOCUMENT_ROOT==>/export/htdocs HTTP_HOST==>uit183.ntdp.intranet UNIQUE_ID==>2e-u6gohASAAAE8d0SIAAAAA
        Try running the script that way and see what you get then.
Re: OT: would this ENV setup make you blow your lid too?
by greenFox (Vicar) on Jun 08, 2006 at 09:15 UTC

    So which part is breaking which part of your code? FWIW I tend to believe that if I am relying on anything being set in the environment for me then I am doing something wrong. If I need something I set it, otherwise I ignore it. I see other people fighting with cron and scripts being run from different shells etc and by and large I don't have those kinds of problems.

    --
    Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho

Re: OT: would this ENV setup make you blow your lid too?
by perrin (Chancellor) on Jun 08, 2006 at 09:24 UTC
    Sorry, I don't get it. Which part of this looks wrong to you? I don't recognize all of those, but it looks pretty standard at first glance.

      It's missing DOCUMENT_ROOT for one. Also the raw query string.

      I have this simple script, that resides in cgi-bin. It gets used via an ssi include directive.

      The script makes thumbnails and returns html listing thumbnail links to the larger images. It's nifty. All the user has to do is make a shtml page and put this <!--#exec cgi="/cgi-bin/gallery"-->

      That one ssi call in that one page runs the whole gallery. The web designer does not need to do anything else to the page. They don't have to make new pages.

      The gallery script determines where it was called from via ENV DOCUMENT_URI, or REQUEST_URI .
      The thumbnails links rendered simply go to $current_http_path?file=x , where x is a number for which file is to be picked.

      If "file" is set, then the gallery script knows that the request is for a picture to be shown med size, not for a view of the whole gallery.

      Comments (stored with storable) and thumbnails are stored off http accessible path

      Never had a problem with this on another box.

      What I am showing you there is ENV straight from a perl compiled script. It's set up for php, zend. That's why it looks goofy.

        So the ENV dump is from a cgi script via an HTTP request or the command line? (I'm still uncertain)

        -derby

        You do realize that when you run a perl script from a shell (ie from the command line) you will not get all of those standard CGI environment variables... It is the web server that sets those environment variables right before it executes the CGI script. When testing scripts from the command line you need to set those variables yourself, or use a module that can simulate a CGI environment like HTTP::Request::AsCGI

        The fact that your TERM environment variable is set to xterm gives it away that you ran this from the shell.

        Oh, this was supposed to be CGI environment. I didn't get that from your post.

        Looks like the exec from your SSI just doesn't propagate the CGI environment variables, probably for security reasons. You might have better results using a #include virtual call to an actual CGI URL if your server supports it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://554207]
Approved by tye
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.