From: John Carter Date: 2002-05-17T16:40:12+09:00 Subject: Re: 10000 images windows shell scripting On Fri, 17 May 2002, Henning von Rosen wrote: > How do I accomplish the simple invocation from a ruby script of a program > that I normally start from the DOS prompt. > The backslash doesn't work, and I don't get the workarounds mantiond for > shell commands to work, or is that not the same thing? > > I feel really newbie-ish about this, and I really need it to work very > soon. Hints/links apprechiated. I'v got 10000 images to vectorize, doing it > by hand won't do any good. Doing it with Ruby would be nice. > > amike via Henning > I use... def cmd( *args) dosArgs = Array.new dosArgs.push args.shift # Get the command... args.each do |arg| if arg =~ %r{^/} then #its an option... dosArgs.push arg else dosArgs.push dosish( arg) end end @log.puts 'CMD> ' + dosArgs.join(' ') dosArgs.unshift('/c') dosArgs.unshift('cmd') system( *dosArgs) end def dosish( dir) dir.gsub( %r{/}, '\\') end Does a couple of other nifty things like convert unixish / to dosish \ in filenames and writes a log of what it is up to @log. John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : john.carter@tait.co.nz New Zealand May contain traces of nuts. This email was packed by mass, not volume. Contents may have settled during distribution. This email is not designed or intended for use in on-line control of aircraft, air traffic, aircraft navigation or aircraft communications; or in the design, construction, operation or maintenance of any nuclear facility. Reader represents and warrants that it will not use or redistribute the email for such purposes.