Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Not quite exiting

by CiceroLove (Monk)
on Aug 24, 2001 at 23:38 UTC ( #107675=perlquestion: print w/replies, xml ) Need Help??

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.

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!


    -><- -><- -><- -><- -><-
    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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://107675]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2021-06-24 06:34 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (123 votes). Check out past polls.