in reply to Re: how to system call that exits
in thread how to system call that exits

I had tried exec earlier. My obstacle was executing a windows program which has spaces in it's file path, i.e., "program files". I've tried it with double quotes, qq[], with and without the (), but it is always halting on 'C:/Program' is not recognized as an internal or external command....
The only solution was to add the program file path to the Environmental variables PATH. I guess exec doesn't work as well as system on Windows OSs.
exec ("qbittorrent.exe") or print STDERR "couldn't exec qbittorrent: $ +!";

Replies are listed 'Best First'.
Re^3: how to system call that exits
by NERDVANA (Priest) on Apr 28, 2024 at 02:10 UTC
    You might consider using Proc::Background, which specializes in running other processes platform-independently (with emphasis on windows), and gives you an object to monitor and kill it. Then you can also write the rest of the script to periodically check for the case of when bittorrent needs restarted, and not be blocked by waiting for system().
Re^3: how to system call that exits
by Corion (Patriarch) on Apr 28, 2024 at 07:12 UTC

    You can also properly quote your filename for cmd.exe and then it will work as well:

    my $cmd = "C:\\Program Files\\qbittorrent\\qbittorrent.exe"; my @args = (...); my @cmd = (qq{"$cmd"}, @args); system @cmd == 0 or warn "Couldn't launch [@cmd]: $! / $^E";
Re^3: how to system call that exits
by BillKSmith (Monsignor) on Apr 30, 2024 at 19:35 UTC
    As Corion pointed out below, with proper quoting, both functions work the same. I find it surprising that system does work as expected without the extra quotes. I suspect that it is a difference between cmd and Windows API.
    Bill