Perl with bash environment vars
I've got a perl script which needs to be aware of bash environment variables. I can use Env, but the problem is not all of the variables exist for the user that the script will be running as.
In bash, we accomplish this by having a shell script called env.sh which does a whole bunch of 'export VARIABLE=VALUE' calls. Our shell scripts, then, do: Code:
source /path/to/env.sh I still get Code:
$ ./testing.pl Thanks! |
I guess you'll have to set those environment variables in ~/.profile or in /etc/profile, or instead of invoking that Perl script directly, you can use a shell script that sets the variables and then proceeds with the Perl script.
|
You can easily parse the file yourself. Here's one way to do it.
The input file: Code:
export STUFF=things Code:
#!/usr/bin/perl Code:
$VAR1 = 'STUFF'; |
Hmm...I may go the shell script route, rather than the parsing route. It's for work, and there are just things which I am and am not supposed to do :)
Thanks to both of you! |
You can use the following construct, to make sure the Perl script won't be invoked independently:
Code:
#! /bin/bash |
Hmmm..that's a neat trick! I never would've thought of it, thank you :)
I'll check back and let you know how it works. |
Hurrah, success! I used a hybrid method:
Code:
#!/bin/bash Thanks so much! |
All times are GMT -5. The time now is 10:02 AM. |