PDA

View Full Version : Multiple versions of Perl


BenP
2010-08-03, 20:02
I’m trying to connect to a 64-bit Oracle database using DBI, but the default installation of Perl on the Unix server is 32-bit. There’s a 64-bit version available, and I can run my script with it if I set PERL5LIB in my .profile accordingly, and either change the #! line to point to the 64-bit version, or run the script from the command line with the 64-bit path (/path/to/64bitperl myscript.cgi).

Now I’m trying to run the script from my browser, and it’s not working. I assume it’s because the browser doesn’t have the appropriate environment variables, but I’ve tried setting $ENV{PERL5LIB} inside the script, and that didn’t work. I’ve also tried adding the path to the 64-bit install to @INC. Is there something else I could try? Is what I’m trying even possible (run 64-bit Perl from a browser when the server’s default is 32-bit)?

AsLan^
2010-08-03, 20:11
How are you running Perl from a browser?

If you mean you're accessing a web server and the CGI is running the script then the CGI will run whichever app is specified on the shebang line.

Brad
2010-08-03, 21:26
How are you running Perl from a browser?

Man, I'm all the time Perling my XMLs over Flash SQL injectors to compile HTML JavaScript streams on my Internets browser. Of course, you can't hack the proxies without PHP-Python port forwarding the dev nulls into an asynchronous thread-safe OSI layer factory.

http://forums.applenova.com/images/ammo/fuuuck.gif

AsLan^
2010-08-03, 21:46
:lol: @thatGIF

That's how I felt the first time I learned about ping and tracert!

BenP
2010-08-04, 08:40
How are you running Perl from a browser?

If you mean you're accessing a web server and the CGI is running the script then the CGI will run whichever app is specified on the shebang line.

Sorry... yes, CGI is running the script. But if I specify the 64-bit Perl installation in the shebang line, without environment variables (from the browser or in Taint mode), Perl can't find any modules (including lib.pm, so I can't add the paths that way...)

AsLan^
2010-08-04, 11:04
You might be able to use a shell script to specify the environmental variables before launching the server.

Something like:

#!/bin/bash
PERL5LIB=/path/to/modules
export PERL5LIB
httpd

Your server is probably already being started by a script, you might just need to find that script and edit it to include the environment variables.

I believe the crux of the issue is that your server is running under a different account to your user account, and the account that it's running under is probably configured without login privileges so you can't just set .profile.

BenP
2010-08-04, 15:23
You might be able to use a shell script to specify the environmental variables before launching the server.

Something like:

#!/bin/bash
PERL5LIB=/path/to/modules
export PERL5LIB
httpd

Your server is probably already being started by a script, you might just need to find that script and edit it to include the environment variables.

I believe the crux of the issue is that your server is running under a different account to your user account, and the account that it's running under is probably configured without login privileges so you can't just set .profile.
Unfortunately I can't do a lot with the server settings thanks to IT. I was able to get this to work by setting the environment variables in a dummy Perl script and then execing the script I actually wanted to run from the dummy one.

AsLan^
2010-08-04, 19:47
That's creative, glad you go it working :)