ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-unix-users
perl-unix-users
RE: [Perl-unix-users] How to execute a shell skript from perl in localcontext
by Justin Devanandan Allegakoen other posts by this author
Nov 24 2005 12:08AM messages near this date
[Perl-unix-users] Re: Reopening STDOUT - howto? | [Perl-unix-users] How to execute a shell skript from perl in local context
-----8<------
system("script") is not my solution, because the script is executed in 
a subshell, and his environment variables are lost after return to perl
-----8<------

Not sure what you mean by localcontext (sic). However if you want
environment variables updated by your Perl code to be visible to the
calling xterm then you can bluff things by doing a waitpid:-

88>  cat waitpid.pl 
#!/usr/bin/perl

use strict;
use warnings;

$ENV{P} = "Hello World" ;

print "\nEnvironment Variable P = $ENV{P}\n\n" ;

print "In this shell type \'echo \$P\'\n" ;
my $pid = system("$ENV{SHELL}") ;
waitpid($pid,0) ;

print "\n$0 is now complete\n AND PID = $pid\n" ;
89>  waitpid.pl 

Environment Variable P = Hello World

In this shell type 'echo $P'
jdallega@pglc3302 81>  echo $P
Hello World
jdallega@pglc3302 82> 

Couple of things to note: the print $0 doesn't print, and the prompt
line numbers get offset.

Cheers,

Just in

_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved