Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Need mouse move??? for Tk, Windows, Excel, system, start

by JamesNC (Chaplain)
on Jan 11, 2006 at 13:25 UTC ( #522434=note: print w/replies, xml ) Need Help??

in reply to Need mouse move??? for Tk, Windows, Excel, system, start

I think it has to do with the Tk window running modal and waiting for system to return it a value. Using 1 as the first argument to system. I got it work the way you want by modifying this section like so:
#warn "path537: '$ENV{PATH}'\n"; my $prob_found; if( $dont_use_start){ system(1, $file_to_run ); }else{ $prob_found = system ( 1, "start", "$file_to_run"); }
You will get 1 returned to your $prob_found, so you will need to change your logic for checking $prob_found to == 0

Replies are listed 'Best First'.
Re^2: Need mouse move??? for Tk, Windows, Excel, system, start
by ff (Hermit) on Jan 12, 2006 at 16:17 UTC
    Thanks JamesNC, that's a good suggestion and it creates the behavior I want. I have rewritten the code as below to use the '1' when using 'start' and to dispatch directly (without the '1') when not using start (i.e. for when I provide the absolute path name of an executable for this routine to run for me.) However, :-(

    When I go to check for the success of running the process by 'system' and 'start' (as seen below by the value printed in 'prob_foundA'), I no longer get a simple-to-check "0-if-OK, non-zero-if-problem" type of return. For example, if the spreadsheet is already in use and I then try running this program, I get the following response:

    prob_foundA: '1608' The process cannot access the file because it is being used by another + process.

    A normal/successful run produces:

    prob_foundA: '756'

    And the number back upon success is not even consistently '756', it might be '1632', '528', '408' such that the '1608' above is also likely unrelated to the failure to run the command via 'system'.

    So, my next question becomes "How do I know whether 'system' ran the command successfully if I use this '1' trick?" (Trying 'perldoc -f system' and 'perldoc -f exec' tells me a lot but I can't see it mentioning the '1' behavior)

    Modified code:

      Well, I can clear up one issue, the number you are seeing is the process id. Checking for success beyond that depends on how you determine success :^)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://522434]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2017-05-27 04:44 GMT
Find Nodes?
    Voting Booth?