in reply to Re: passing setup via pipeline
in thread passing setup via pipeline

hmmm

I was thinking to use another pipeline, for example:
open(MYPIPE,"source .aliases|");
my $mypipe = <MYPIPE>;
open(COM,"$mypipe | $run_cmd 2>&1 |") || die "Could not execute command\n";

$_ = <COM>;
do{
$txt -> insert('end',$_);
}

while(<COM>);
close(COM);


what do you think, does it have a chance
BR
Michael

Replies are listed 'Best First'.
Re^3: passing setup via pipeline
by cdarke (Prior) on May 25, 2010 at 10:17 UTC
    First, 'source' is a c-shell or bash built-in, so you need to specify the shell.
    Second, that would just create the aliases in one child process. The second open will run a different process without the aliases.
Re^3: passing setup via pipeline
by ikegami (Patriarch) on May 25, 2010 at 17:29 UTC

    I think you want open3 or similar.

    open3(*TO_CHLD, *FR_CHLD, undef, 'bash')

    Then you can print out commands to TO_CHLD and collect the output from FR_CHLD. Then you can issue shell commands including aliases, and the state of the shell (incl current work dir and environment settings) will persist between commands.

    Hum, actually, you would need a pty instead of a pipe to get interactive behaviour. IPC::Run can do all of this pretty easily, so it's probably a better choice than open3

      ... Then you can print out commands to TO_CHLD and collect the output from FR_CHLD.

      I think one of the tricky things with open3 is how to correctly detect the end of multi-line responses, e.g. when issuing commands like ls -l (or the respective alias), as the pesistent shell won't close the pipe when done with the command.

        I don't think the OP needs to isolate responses. I take "I'm writing a Tk entry that emulates term" to mean he wants to build a console.
Re^3: passing setup via pipeline
by Corion (Patriarch) on May 25, 2010 at 08:00 UTC

    Your idea does not make any sense to me.