CiceroLove has asked for the wisdom of the Perl Monks concerning the following question:

Okay I have a very small two line script that does three things. It sets the PATH, exports the PATH, and puts me in a bash shell. Please don't ask me why I have to make this file, I just do. I know there are other ways to do this automatically but it's a long story involving pain and yelling. This is the script:
#!/usr/local/bin/perl $result = system("PATH=$PATH:/usr/local:/usr/local/bin:/usr/ccs:/usr/c +cs/bin:/usr/ucb; export PATH; bash;"); print $result . "\n";
My question is this: Why is the result is not printed after the script runs? Whenever I type exit on the command line, then the result is printed. It's as if I am inside a constantly running perl script. I have tried sticking an exit; on the end of my script but that does nothing. Thanks for your help.

CiceroLove
Fates! We will know your pleasures: That we shall die, we know; 'Tis but the time, and drawing days out, that men stand upon. - Act III,I, Julius Caesar

Replies are listed 'Best First'.
Re: Not quite exiting
by jwest (Friar) on Aug 24, 2001 at 23:43 UTC
    Well, bash is a shell and the Perl script won't continue until you exit from bash (ie, typing 'exit' on the command line), which finishes up the system() command.

    If I understand you correctly, you're getting the correct behavior.


    Hope this helps!

    --jwest

    -><- -><- -><- -><- -><-
    All things are Perfect
        To every last Flaw
        And bound in accord
             With Eris's Law
     - HBT; The Book of Advice, 1:7
    
Re: Not quite exiting
by dga (Hermit) on Aug 25, 2001 at 00:42 UTC

    You will need to exec bash.

    use strict; my $shell='/bin/bash'; #full path to bash here $ENV{PATH}.=":/usr/local:/usr/local/bin:/usr/ccs:/usr/ccs/bin:/usr/ucb +"; exec $shell; #exec $shell '-bash'; #if you want to pretend to be a login shell

    Also I am using perl to setup the path since no reason to call out for that since the bash will inherit perls version of the PATH.