in reply to Re: Change shell within Perl
in thread Change shell within Perl

Ok, the question here was how to _NOT_ having to enter exit to continue? Like I want something like: do stuff; change to another shell; do stuff; change back (or enter yet another shell)...
And not type exit... Seems like its abit tricky... hmm...

Well, yes, the $ENV{SHELL} helped me there.

Replies are listed 'Best First'.
Re^3: Change shell within Perl
by blazar (Canon) on Sep 13, 2005 at 15:59 UTC
    It all depends on "do stuff". Basically it seems you do want to start an interactive shell. Don't you? Then you have to tell it you're finished in some way or another, to return to the main flow of your Perl program. So this won't be a 'real' answer to your question, but if you don't want to type exit, alternatives are logout or ^D (at the beginning of a line).

    Or else "do stuff" is a single command in the shell you're opening. But then why not calling that command directly? All in all I suspect XY here: you really want to do "Y", but think you need "X" to do "Y", thus you ask "X" whereas you should ask "Y" in the first place...

      Something like:
      system ("tcsh");
      system ("java -jar gogo.jar");
      system ("bash");
      system ("mld gogo");
        Er, why do you need to run tcsh before you run java?
        What I was trying to say, and what BUU tried to say as well, is that while you may indeed have good reasons to do "something like" the above, all in all it seems awkward.

        Just like java -jar gogo.jar has to terminate before the system call returns, so has -say- bash. And to terminate, if it is interactive, it has to be told so.

        Now the point is: if you launch those shells, it seems that you want to allow the users of your program to perform arbitrary operations, don't you? If so, I don't see any obvious alternative to the current behaviour. Or else you should change the whole logic around...

        Last, I may be utterly wrong, but the above also suggests that your program may look much like a shell script. If this is the case, you may consider writing an actual shell script instead. If not, then plainly ignore this piece of advice!

Re^3: Change shell within Perl
by Anonymous Monk on Sep 13, 2005 at 21:11 UTC
    What do you mean by change? Do you want a new window?