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

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

Replies are listed 'Best First'.
Re^4: Change shell within Perl
by Ace128 (Hermit) on Sep 13, 2005 at 17:35 UTC
    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?
        It's just an example, but it's something crappy like that here...
      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!