Duane Johnson
2005-Jun-15 16:04 UTC
Is there a simple way to find out if a shell command exists via Ruby?
I would like to write a unit test that checks to make sure that ImageMagick is installed and working--ideally, I''d like to see if the ''convert'' shell command can be executed before actually executing it. Is there a simple way to do this without knowing where the actual ''convert'' file resides (assuming it''s in the path environment)? Thanks, Duane Johnson (canadaduane)
PJ Hyett
2005-Jun-15 16:09 UTC
Re: Is there a simple way to find out if a shell command exists via Ruby?
If you''re using ImageMagick in conjunction with RMagick, when you install RMagick it''ll run some tests during the post-install to make sure everything is working properly. -PJ On 6/15/05, Duane Johnson <duane.johnson-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I would like to write a unit test that checks to make sure that > ImageMagick is installed and working--ideally, I''d like to see if the > ''convert'' shell command can be executed before actually executing > it. Is there a simple way to do this without knowing where the > actual ''convert'' file resides (assuming it''s in the path environment)? > > Thanks, > Duane Johnson > (canadaduane) > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Trevor Squires
2005-Jun-15 16:40 UTC
Re: Is there a simple way to find out if a shell command exists via Ruby?
On 15-Jun-05, at 9:04 AM, Duane Johnson wrote:> I would like to write a unit test that checks to make sure that > ImageMagick is installed and working--ideally, I''d like to see if the > ''convert'' shell command can be executed before actually executing it. > Is there a simple way to do this without knowing where the actual > ''convert'' file resides (assuming it''s in the path environment)?Hey Duane "which" is a unix command that finds the first executable (of the supplied name) in your PATH i.e. `which convert` (note the backtics in ruby) ought to do the trick If you''re not on unix you can step thru the PATH manually. ENV[''PATH''].split('';'') is a good starting point... Trevor
Dee Zsombor
2005-Jun-16 07:54 UTC
Re: Is there a simple way to find out if a shell command exists via Ruby?
How about simply executing the comand with a harmless paramater to do something trivial like echoing version number? Then compare output with one expected, if matches ok if not you dont ... On 6/15/05, Trevor Squires <trevor-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote:> > On 15-Jun-05, at 9:04 AM, Duane Johnson wrote: > > > I would like to write a unit test that checks to make sure that > > ImageMagick is installed and working--ideally, I''d like to see if the > > ''convert'' shell command can be executed before actually executing it. > > Is there a simple way to do this without knowing where the actual > > ''convert'' file resides (assuming it''s in the path environment)? > > Hey Duane > > "which" is a unix command that finds the first executable (of the > supplied name) in your PATH > > i.e. `which convert` (note the backtics in ruby) ought to do the trick > > If you''re not on unix you can step thru the PATH manually. > > ENV[''PATH''].split('';'') is a good starting point... > > Trevor > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- http://deezsombor.blogspot.com