Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Call shell script variables in perl

by Eliya (Vicar)
on Mar 21, 2011 at 10:41 UTC ( #894466=note: print w/ replies, xml ) Need Help??


in reply to Call shell script variables in perl

system runs a subprocess, and because a subprocess gets its own copy of the environment, you cannot set/modify an environment variable from within a subprocess such that it will be available to the parent process (your Perl script here).  In other words, the new subprocess' environment is gone as soon as the process has ended, i.e. when system returns.  Exporting won't help.

But you could print the variable's value to stdout in the shell script, and capture it in the Perl script (e.g. via backticks).


Comment on Re: Call shell script variables in perl
Download Code
Re^2: Call shell script variables in perl
by k_manimuthu (Monk) on Mar 21, 2011 at 11:30 UTC

    Thanks for your information. I am showing (STDOUT) more information to the end user. I want to use the particualar variable only in my perl program. I will get the output as you metioned method and do regex stuff to to get the result. Thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://894466]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-12-25 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls