• open documents under windows from a perl/tk-Programm

    From pit@21:1/5 to All on Wed Jun 8 08:22:33 2016
    Hi Folks,

    whats the best way to open documents with several filetypes from a perl/tk-program under windows.

    Thanks
    Pit

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From $Bill@21:1/5 to pit on Thu Jun 9 05:26:36 2016
    On 6/8/2016 08:22, pit wrote:
    Hi Folks,

    whats the best way to open documents with several filetypes from a perl/tk-program under windows.

    What does open mean to you? Do you mean open to read it into the Tk program
    or do you mean open it with the app that is intended to process that type of file (as in 'start' from command line). A few file type examples would also help.

    A bit of detail would help.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From pit@21:1/5 to All on Mon Jun 13 03:20:37 2016
    Am Mittwoch, 8. Juni 2016 17:22:34 UTC+2 schrieb pit:
    Hi Folks,

    whats the best way to open documents with several filetypes from a perl/tk-program under windows.

    Thanks
    Pit

    I mean open it with the app that is intended to process that type of file as in 'start' from command line.

    Pit

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From $Bill@21:1/5 to pit on Mon Jun 13 05:59:35 2016
    On 6/13/2016 03:20, pit wrote:
    Am Mittwoch, 8. Juni 2016 17:22:34 UTC+2 schrieb pit:
    Hi Folks,

    whats the best way to open documents with several filetypes from a perl/tk-program under windows.

    Thanks
    Pit

    I mean open it with the app that is intended to process that type of file as in 'start' from command line.

    Still not much detail. Do you want to do multiple of these and
    background the apps? Do you want to do them one at a time? Do
    you know what apps are to process the files or do you want to
    use the default process? Etc, etc, etc.

    You could use `` or 'system' or 'fork' and 'exec' or read perlipc
    man page for other possible solutions.

    On Windoze, I would probably use 'system' with a start command and
    possibly background it with & if you don't need to wait for it.
    But you really should describe what you're doing for a proper response.

    Your OS would in a large part determine how you would want do it -
    you didn't state that either.

    perlfaq8 says:

    How do I start a process in the background?
    (contributed by brian d foy)

    There's not a single way to run code in the background so you don't have to
    wait for it to finish before your program moves on to other tasks. Process
    management depends on your particular operating system, and many of the
    techniques are covered in perlipc.

    Several CPAN modules may be able to help, including IPC::Open2 or
    IPC::Open3, IPC::Run, Parallel::Jobs, Parallel::ForkManager, POE,
    Proc::Background, and Win32::Process. There are many other modules you might
    use, so check those namespaces for other options too.

    If you are on a Unix-like system, you might be able to get away with a
    system call where you put an "&" on the end of the command:

    system("cmd &")

    You can also try using "fork", as described in perlfunc (although this is
    the same thing that many of the modules will do for you).

    STDIN, STDOUT, and STDERR are shared
    Both the main process and the backgrounded one (the "child" process)
    share the same STDIN, STDOUT and STDERR filehandles. If both try to
    access them at once, strange things can happen. You may want to close or
    reopen these for the child. You can get around this with "open"ing a
    pipe (see "open" in perlfunc) but on some systems this means that the
    child process cannot outlive the parent.

    Signals
    You'll have to catch the SIGCHLD signal, and possibly SIGPIPE too.
    SIGCHLD is sent when the backgrounded process finishes. SIGPIPE is sent
    when you write to a filehandle whose child process has closed (an
    untrapped SIGPIPE can cause your program to silently die). This is not
    an issue with "system("cmd&")".

    Zombies
    You have to be prepared to "reap" the child process when it finishes.

    $SIG{CHLD} = sub { wait };

    $SIG{CHLD} = 'IGNORE';

    You can also use a double fork. You immediately "wait()" for your first
    child, and the init daemon will "wait()" for your grandchild once it
    exits.

    unless ($pid = fork) {
    unless (fork) {
    exec "what you really wanna do";
    die "exec failed!";
    }
    exit 0;
    }
    waitpid($pid, 0);

    See "Signals" in perlipc for other examples of code to do this. Zombies
    are not an issue with "system("prog &")".

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)