[Tutor] Checking for executables
Bradford R. Bowman
bowman at mazirian.com
Sun Jul 24 20:02:43 CEST 2005
I am writing a script that is a wrapper for a number of other utilities
often found on *nix workstations, including the rar and par2 utilities.
I want the script to check whether those utilities are installed at the
outset (and not when they are needed later on in the script, which I
suppose I could just use exception handling to do). Here's what I have
now:
import commands
for cmd in ('rar', 'par2'):
if commands.getstatusoutput('which ' + cmd)[0] != 0:
print "Fatal error: cannot find the %s executable." % cmd
sys.exit()
This appears to work, but, as I'm just beginning with
python/programming, I thought there might be something in the standard
library that just does what I want. Am I recreating the wheel here?
--
Bradford R. Bowman
GnuPG Public Key available at:
http://mazirian.com/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/tutor/attachments/20050724/7cb148f0/attachment.pgp
More information about the Tutor
mailing list