NAME

Shell::GetEnv - extract the environment from a shell after executing commands

SYNOPSIS

use Shell::GetEnv;

$env = Shell::GetEnv->new( $shell, $command );
$status = $env->status;
$envs = $env->envs( %opts )
$env->import_envs( %opts );

DESCRIPTION

Shell::GetEnv provides a facility for obtaining changes made to environmental variables as the result of running shell scripts. It does this by causing a shell to invoke a series of user provided shell commands (some of which might source scripts) and having the shell process store its environment (using a short Perl script) into a temporary file, which is parsed by Shell::Getenv.

Communications with the shell subprocess may be done via standard IPC (via a pipe), or may be done via the Perl Expect module (necessary if proper execution of the shell script requires the shell to be attached to a "real" terminal).

The new environment may be imported into the current one, or may be returned either as a hash or as a string suitable for use with the *NIX env command.

METHODS

EXPORT

None by default.

SEE ALSO

There are other similar modules on CPAN. Shell::Source is simpler, Shell::EnvImporter is a little more heavyweight (requires Class::MethodMaker).

This module's unique features:

DEPENDENCIES

The YAML::Tiny module is preferred for saving the environment (because of its smaller footprint); the Data::Dumper module will be used if it is not available.

The Expect module is required only if the expect option is specified.

AUTHOR

Diab Jerius, djerius@cpan.org

CONTRIBUTORS

COPYRIGHT AND LICENSE

Copyright 2007 Smithsonian Astrophysical Observatory

This software is released under the GNU General Public License. You may find a copy at

      http://www.gnu.org/licenses