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

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
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2016-05-26 16:00 GMT
Find Nodes?
    Voting Booth?