in reply to real static perl

bobb,

depending on your access to the server you just might be SOL. If all you have is FTP access, you probably won't be able to do things like make the file (perl executable) executable as far a linux goes. Also depending on the setup, you could potentially not have access to your rc files (bashrc, cshrc, bash_profile) and would thus be unable to set environment variables needed in other posted answers. Depending on setup, you may or may not be able to set environment variables at all since the rc files are not read in certain circumstances (like cron jobs, httpd may be the same). Just more food for thought.

--marc

Replies are listed 'Best First'.
Re^2: real static perl
by almut (Canon) on Apr 19, 2007 at 23:28 UTC
    If all you have is FTP access, you probably won't be able to do things like make the file (perl executable) executable as far a linux goes.

    Strictly speaking, on Linux, an executable doesn't need to be executable :)  You can always run it directly via the dynamic loader. If you don't believe it, try the following:

    Copy the perl binary to some temp directory

    $ cp `which perl` /tmp

    Remove the executable bit

    $ chmod -x /tmp/perl $ ls -l /tmp/perl -rw-r--r-- 1 ab ab 1061700 Apr 20 00:47 /tmp/perl

    Now, if you try to run it normally, you'd of course get

    $ /tmp/perl -v bash: /tmp/perl: Permission denied

    but if you use the dynamic loader, it works without a hitch

    $ /lib/ld-linux.so.2 /tmp/perl -v This is perl, v5.8.8 built for x86_64-linux-thread-multi (...)
    Also depending on the setup, you could potentially not have access to your rc files (bashrc, cshrc, bash_profile) and would thus be unable to set environment variables needed

    You don't necessarily need to. If you have mod_env available, you can conveniently set them from your apache config (e.g. for the CGI directory in question):

    SetEnv LD_LIBRARY_PATH /path/to/private/shared/libs

    This even works with .htaccess files, so you don't need write access to the main httpd.conf. Also, as I tried to point out, it's probably not even a good idea to set LD_LIBRARY_PATH system-wide from some rc file (too many side effects if you mess with important libs on that scale...).

      almut,

      congrats (and ++) ... you just tought an old dog a new trick. 10+ years in UNIX/Linux and I've never seen the ld-linux trick (well i may have but forgotten). i like it, thanks!!

      no time to get into the rest ... never tried setting ENV vars in a .htaccess, not saying you're wrong, just never tried it. in a nutshell, my basic argument against the rest of the post is that if bobb doesn't have access enough to do the things suggested, he certainly won't have access to the httpd.conf, apachectl or global LD_LIBRARY_PATH (i know you suggest against it as i would agree). on the .htaccess ENV thing, would that work? the file would be in some user's directory but httpd would most likely not be running as that user. i've never needed to look but this would make sense only if the CGI was executed as the user who owned it, not the user running the httpd process (nobody, daemon whomever).

      anyway, thanks for the cool trick and for making me think!!

      --marc
Re^2: real static perl
by bobb (Acolyte) on Apr 20, 2007 at 07:01 UTC
    Access is convoluted and exasperating, but with patience I can get quite a bit done. Ftp provides "chmod", but not "chown". I can create a cgi script on my home machine, upload it with ftp, make it executable with chmod +x, then browse the script to execute it. I've learned quite a bit about the server, but its perl and glibc are very old, and incompatible with anything I do on my home machine.