[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] [python]checke at et externt program findes



On Mon, Jun 05, 2006 at 10:11:14AM +0200, Atte André Jensen wrote:
> Jeg har et python script der bruger en del eksterne programmer (fx gv) 
> som jeg kalder via os.system, fx som "gv" altså uden sti. Nu vil jeg 
> gerne lave et check for om disse programmer er tilstede på systemet, men 
> hvordan gør jeg smartest det? Jeg ved jo ikke (og er ligeglad med) 
> hvilken sti de ligger i, så jeg kan ikke checke om filen findes og er 
> eksekverbar, hvilket var min første tanke.

Jeg ved ikke om Python har en speciel måde at håndtere dette, men jeg
bruger normalt kommandoen 'command -v foobar' for at checke om
'foobar' findes i $PATH; fejler den, så findes 'foobar' ikke i $PATH.

Du burde kunne lave en Python funktion til at kalde 'command -v' via
os.system og checke returværdien.

Mvh
Brix
-- 
Henrik Brix Andersen <sslug@sslug>
Gentoo Metadistribution | Mobile computing herd


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-07-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *