Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Proc::Background does not take file path with spaces

by BrowserUk (Pope)
on Apr 27, 2012 at 10:48 UTC ( #967583=note: print w/replies, xml ) Need Help??


in reply to Proc::Background does not take file path with spaces

Looking inside the Win32 component of Proc::Background it does some pretty dubious manipulations with the program component of its arg(s), including if, -- after it has done some other incomprehensible manipulations -- the length of the command argument is 0, then it wraps that zero length arg in quotes:

if (length($arg) == 0 or $arg =~ /\s/) { $arg = "\"$arg\""; }

None of which bodes well for success.

If all you need is to start a process in the background, a simple:

my $pid = system 1, 'c:/program Files (x86)/vs.exe';

Does the job.

if( kill $pid, 0 ) { ... will tell you if it is still running.

kill $pid, 3; will terminate it.

waitpid $pid,0; my $retcode = $?; will get the return code.


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.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: Proc::Background does not take file path with spaces
by SuicideJunkie (Vicar) on Apr 27, 2012 at 13:34 UTC

    On a windows command line, your parameters are all (white?)space separated. If you want a zero-length parameter you need to double quote it so it isn't ignored, like so:

    USAGE: mangle.exe [filename] [password] [index number] mangle.exe unprotected.dat "" 42

    Parameters that are all whitespace have the same problem and solution.

    No idea on why it had to be done that way though.

      If you want a zero-length parameter

      Hm. Okay, you got me there. Mind you, in 30 years I don't remember ever having used a command that took a "zero length parameter".

      Every command I'm aware of that takes a password has an option to supply it. And optional parameters always come at the end.


      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.

      The start of some sanity?

        Hi Guys I end up using the following
        use Win32; $CommandNew = Win32::GetShortPathName("C:\\Program Files (x86)\\vs.exe +"); Proc::Background->new($CommandNew);
        Thanks for looking

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://967583]
help
Chatterbox?
[robby_dobby]: I always thought everything on the other side of Suez to be Africa. That's an entire continent
[LanX]: Sinai_Peninsula
[robby_dobby]: choroba: If you're talking of Eurasia, it's only true of the erstwhile Constantinople/ Ottoman empire
[LanX]: yes correct, but Sinai is not on the other side
[LanX]: Organizing a YAPC in a tourist ressort is not a bad idea ...
[LanX]: ... and we could swap to our first YAPC Africa the following year when organizing in Hurghada
[robby_dobby]: LanX: Well volunteered!
[LanX]: ... just ... ppl would be to afraid of terrorist attacks
[choroba]: python guerrila?
[robby_dobby]: if I do make it, I can at least savour their local tea! :-)

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (15)
As of 2017-04-24 16:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (442 votes). Check out past polls.