in reply to Using Proc::Background and Win32

I ran both the ASSOC and FTYPE commands in the cmd prompt and they are good.

Assoc & ftype are used by the shell to run the appropriate executable.

P::B::W32 uses Win32::Process (which is a thin wrapper around CreateProcess()) which expects the name of the executable as its first argument.

Try passing 'cmd' as the first word.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Using Proc::Background and Win32
by mmartin (Monk) on Oct 18, 2013 at 19:07 UTC
    Hey BrowserUIK, thanks for the reply!

    Ok assuming you meant pass "cmd" before my script name, here's what happened:
            *The first line is just regular output from main_script.pl...
    New Proc::Background Command:
    $proc = Proc::Background->new("cmd bg_script.pl $speed_ARG \"$ticker_ARG\" $start_ARG $end_ARG $color_ARG");
    C:\Script_dir>main_script.pl EXECUTING bg_script.pl ON WIN32: A subdirectory or file .exe already exists. Error occurred while processing: .exe. A subdirectory or file bg_script.pl already exists. Error occurred while processing: bg_script.pl. A subdirectory or file --speed already exists. Error occurred while processing: --speed. A subdirectory or file 5 already exists. Error occurred while processing: 5. A subdirectory or file --start-in already exists. Error occurred while processing: --start-in. A subdirectory or file now already exists. Error occurred while processing: now. A subdirectory or file --end-in already exists. Error occurred while processing: --end-in. A subdirectory or file end-of-day already exists. Error occurred while processing: end-of-day. A subdirectory or file --ticker-color already exists. Error occurred while processing: --ticker-color. A subdirectory or file 0xFF0000 already exists. Error occurred while processing: 0xFF0000.
    FYI: The one arg that has the \"...\" around it is because that command might and usually
    will contain whitespace.

    Where is it getting the ".exe" from in that first error, is that from the "cmd" command? Also, it
    looks like it's giving errors on my CLI Args too.

    Thanks again for the reply!


    Thanks,
    Matt

      It was worth a try.

      BTW: Have you read this in the docs?

      For Win32 operating systems:
      The Win32::Process module is always used to spawn background processes on the Win32 platform. This module always takes a single string argument containing the executable's name and any option arguments. In addition, it requires that the absolute path to the executable is also passed to it. If only a single argument is passed to new, then it is split on whitespace into an array and the first element of the split array is used at the executable's name. If multiple arguments are passed to new, then the first element is used as the executable's name. If the executable's name is an absolute path, then new checks to see if the executable exists in the given location or fails otherwise. If the executable's name is not absolute, then the executable is searched for using the PATH environmental variable. The input executable name is always replaced with the absolute path determined by this process. In addition, when searching for the executable, the executable is searched for using the unchanged executable name and if that is not found, then it is checked by appending `.exe' to the name in case the name was passed without the `.exe' suffix. Finally, the argument array is placed back into a single string and passed to Win32::Process::Create.</i></blockquote>

      Personally, I think the sheer number of generic background process starters on cpan is a string indication that their goal is a flawed concept. I've tried many of them and haven't fond one that works as well as a simple:

      if( $^O =~ 'mswin' ) { my $pid = system 1, $command; } else { ##whatever is appropriate on *nix. }

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        Hey BrowserUK, thanks AGAIN for the reply!

        Yea, I did see that... See my most recent comment that I must have been writing as you
        were writing yours.


        I'm definitely NOT married to the Proc::Background way, so as long as I can execute this
        script in the background and also have the ability to check if it's still running or not, then
        that's fine by me...


        Thanks Again,
        Matt