in reply to Change shell within Perl
I was wondering if anyone here has some bright ideas on how to (tempurary) change a shell from within a Perl script without the script actually "end"! I mean, say I do "system ("bash");", the script won't continue until I do "exit" in that newly opened bash shell. Is it even possible?Indeed this is what system should do in the first place. Did you try it? Or do you want to do something different?
[blazar@zion blazar]$ perl -le 'print 1; system "bash"; print 2' 1 [blazar@zion blazar]$ whoami blazar [blazar@zion blazar]$ exit 2 [blazar@zion blazar]$
Ah, yea, and how to figure out _what_ shell I'm currently in?Well, it depends on what you mean exactly with "shell I'm currently in". If the perl script is launched from a shell, and thus is a child of it, then it can check the cmdline of the parent process. Is this what that you want?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Change shell within Perl
by Ace128 (Hermit) on Sep 13, 2005 at 15:12 UTC | |
by blazar (Canon) on Sep 13, 2005 at 15:59 UTC | |
by Ace128 (Hermit) on Sep 13, 2005 at 17:35 UTC | |
by BUU (Prior) on Sep 13, 2005 at 20:38 UTC | |
by Ace128 (Hermit) on Sep 13, 2005 at 21:21 UTC | |
by blazar (Canon) on Sep 14, 2005 at 09:06 UTC | |
by Anonymous Monk on Sep 13, 2005 at 21:11 UTC |