From: Tobias Reif Date: 2002-05-29T20:37:20+09:00 Subject: Re: OS independent scripts, system calls on Windows and Linux Dossy wrote: > Unlike Unix, where "date" is a real command that can be executed > by another program, in DOS the "date" command is a shell builtin, > part of COMMAND.COM (or CMD.EXE, or whatever DOS shell you're > running). So, this isn't a bug in Ruby at all, it's a misunderstanding > of yours how things are supposed to work. I enter commands at the "DOS prompt". Now if it's possible, I'd like to have a mechanism in Ruby to which I can pass the exact same commandline, and they get executed, just as in the commandline. If it's possible, I'd like the mechanism to automatically handle the differences behind the scenes, so that I can pass it ver, date, whatever, just as in the commandline window, and it just works. BTW, here's my current .bat file in case anyone's interested in what I'm doing: ([OT] does anyone know how I can stop the batch script as soon as one command returned an error? I just begun learning (ugly) .bat scripting.) ----- @echo off rem rem should run on Windows ME/98/95, rem also XP and 2000/NT rem (ran on: ME, ) rem rem "rem" lines are comments (remark, remove) rem rem in the project directory, run rem all rem rem the source XML always gets validated rem to validate all XML documents, run rem all -va rem (validate all) rem for validation with remote DTDs one must be online rem rem echo validating source XML: domcount svg-links.xml rem echo source to xhtml: java com.icl.saxon.StyleSheet -o links.xhtml svg-links.xml links2xhtml.xslt rem if not "%1" == "-va" goto afterXhtmlVal echo validating xhtml: domcount links.xhtml :afterXhtmlVal rem echo source to dot: java com.icl.saxon.StyleSheet -o links.dot svg-links.xml links2dot.xslt rem echo dot to svg: dot -Tsvg -o links.svg links.dot rem if not "%1" == "-va" goto afterSvgVal echo validating SVG: domcount links.svg :afterSvgVal rem ----- > Try this: > > C:\WINDOWS\COMMAND>ver [...] > C:\WINDOWS\COMMAND>ruby -e 'puts `mem`' > C:\WINDOWS\COMMAND>ruby -e 'puts system("mem")' all work > See, backticks (`) and #system both simply search the PATH > environment variable for an executable that you've named. > If it doesn't find it (like in the case of "date" or "ver" > which are both shell builtins and not standalone executables) > ... well ... it won't find it, and not be able to execute > it. C:\WINDOWS>ruby -e "puts `dot -V`" dot version 1.8.4 (Thu Apr 18 15:08:04 EDT 2002) C:\WINDOWS>ruby -e "puts `domcount`" Usage: DOMCount [options] both are on the path and work OK; but: C:\WINDOWS>ruby -e "puts `java -version`" -e:1: command not found: java -version C:\WINDOWS>java -version java version "1.3.0_01" [...] I added Java to the path, it works, but not from Ruby, and the Java path is not visible in path. Windows seem to be a mess. Unless there's an error above; what can I do to call Java from Ruby? Would it be possible for Ruby to find Java, by looking in the right places, or asking the "DOS shell", which does know where it is? Tobi -- http://www.pinkjuice.com/