persistant environment data

S

sburg

I am trying to convert the following line from a makefile into perl:
.. shell_script_to_get_env_data && java Main

When run on a Unix command line the
.. shell_script_to_get_env_data
sets some env variables.

Then some objects instantiated from Main.java need to use
those env variables.

The following perl lines don't work:
system(". shell_script_to_get_env_data");
system("java Main");
Main fails because its shell doesn't have the env variables set.

How do I put these commands together in Perl so that the environment
variables set up by the shell script are accessable by the Java
program?

Thanks,
Shawna
 
V

Vlad Tepes

sburg said:
I am trying to convert the following line from a makefile into perl:
. shell_script_to_get_env_data && java Main

When run on a Unix command line the
. shell_script_to_get_env_data
sets some env variables.

Then some objects instantiated from Main.java need to use
those env variables.

The following perl lines don't work:
system(". shell_script_to_get_env_data");
system("java Main");
Main fails because its shell doesn't have the env variables set.

How do I put these commands together in Perl so that the environment
variables set up by the shell script are accessable by the Java
program?

How about

system("./shell_script_to_get_env_data && java Main");

Or you could set the environment in perl, then run java:

$ENV{myvar} = "somevalue";
system("java Main");
 
C

Chris Mattern

sburg said:
I am trying to convert the following line from a makefile into perl:
. shell_script_to_get_env_data && java Main

When run on a Unix command line the
. shell_script_to_get_env_data
sets some env variables.

Then some objects instantiated from Main.java need to use
those env variables.

The following perl lines don't work:
system(". shell_script_to_get_env_data");
system("java Main");
Main fails because its shell doesn't have the env variables set.

How do I put these commands together in Perl so that the environment
variables set up by the shell script are accessable by the Java
program?
Have you tried
system(". shell_script_to_get_env_data && java Main");
?

Chris Mattern
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top