in reply to Start an MS window in background from a perl script

& is a sh thing. The same can be achieved using start in cmd.

Update: Better yet, the Windows-specific system(1, "...command...");.

Replies are listed 'Best First'.
Re^2: Start an MS window in background from a perl script
by syphilis (Archbishop) on Sep 19, 2007 at 14:14 UTC
    & is a sh thing

    But, in a sense, that's an oversimplification. I mean, if I run (in Cygwin's bash shell):
    Rob@desktop2 ~ $ perl -e 'system "notepad &"'
    then that works as intended. But if I invoke ActivePerl (in the very same Cygwin shell) by running:
    Rob@desktop2 ~ $ /cygdrive/c/_32/ap822/bin/perl -e 'system "notepad &"'
    then I get the precise (undesired) behaviour as described by the op - where I get told that &.txt does not exist.

    Is it simply a case of "ActivePerl always assumes that it's being run in the cmd shell" ? ... or is there a more erudite way of explaining this ?

    Cheers,
    Rob

      There's no assumption being made as to which shell launched Perl. As documented, the shell used by system is constant.

      On most platforms, that shell is /bin/sh (no matter what the user's login shell is or which process launched perl), so system's argument must be a sh command. & can be used to run a background task in sh.

      On Windows (cygwin aside), that shell is cmd, so system's argument must be a cmd command. start can be used to run a background task in cmd.

Re^2: Start an MS window in background from a perl script
by rlambert7 (Acolyte) on Sep 19, 2007 at 17:30 UTC
    Thanks everyone for your posts. The suggestion of using 'system(1, "...command...");" worked. THANKS.

    Interestingly, before I even tried to use "system", I thought there might be more than one parameter I could pass to it, but I couldn't find documentation on it, so please let me ask a couple of questions about Perl documentation.

    I tried "perldoc system", but it said there was no documentation on "system". Where/how could I find the syntax for "system", and a brief synopis?

    Also, how can I list all of the functions contained in a Perl module, and how do I find a synopsis and syntax of a specific function within a module? (For example, "perldoc Win32::TestGui" gives me some information, but not all of what I would need to effectively use that module).

    Thanks, again.

      To get information on functions from perldoc you use the -f switch.

      So it's

      perldoc -f system

      OS-specific differences are documented in perlport.

      Your last paragraph is really unrelated. Why don't you start a new SoPW thread?