Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Check for another program availability

by afoken (Canon)
on Apr 11, 2021 at 09:29 UTC ( #11131104=note: print w/replies, xml ) Need Help??


in reply to Check for another program availability

If the program can be found in $ENV{'PATH'} when it is installed, then just trying to execute it will either succeed or fail, no need to search first. See system and exec.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: Check for another program availability
by Radiola (Monk) on Apr 14, 2021 at 06:20 UTC

    Iíll sometimes do this as an explicit pre-flight check. If so, itís either because:

    1. I use this program deep in the code and I donít want to have to unroll a bunch of state (or fail and leave a broken mess) if I get halfway through and then find a critical external program is missing.

    2. I want to be unusually user-friendly for a Unix program. Seriously, sometimes the failure that results ďnaturallyĒ is misleading and will leave the user (usually me) scratching their head and having to troubleshoot. I can save them (myself) a bunch of time if I simply tell them (me) what's wrong.

    I agree thereís no point to checking for availability on the line before you try to run the program; you might as well just process the error from system or whatever.

    – Aaron
    Preliminary operational tests were inconclusive. (The damn thing blew up.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11131104]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2021-06-15 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (68 votes). Check out past polls.

    Notices?