From: Jason Mayer Date: 2006-11-19T03:45:46+09:00 Subject: Re: newbie: how to script windows commands with ruby? ------=_Part_28766_25619902.1163875542740 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I feel ashamed of myself, but I hadn't actually tried using what I thought to be the *nux only command. Your example worked flawlessly, thanks! (and now I get to start on my project!) On 11/18/06, Paul Lutus wrote: > > Jason Mayer wrote: > > > Hi! > > > > I've been learning ruby for a little while, but I'm having trouble > > figuring out how to do this (and I must be using the wrong keywords in > > my google search). I do tech support, and I'm looking to automate > > some basic troubleshooting over a web interface for my coworkers and > > new hires. > > > > What I'd like to do is script the windows ping command and scrape the > > results. Anyone know where I can find good references on this? > > > > So I guess my question could be clarified as How do I script windows > > command line commands via ruby (I understand that in linux I could > > just use `ping xxx`)? > > Yes, that's right, and it works in Windows (under Ruby) the same way. But > clearly this didn't work for you. So, what did you try, and what was the > result? > > Have you tried: > > data = `ping -n 1 hostname`.chomp > > > The second question would be 'How do I scrape the output of a windows > > cmd.exe command and use it in the rest of my script?' > > This should work: > > data = `cmd.exe /C command`.chomp > > Again, it would help to see what you tried and what you got. > > -- > Paul Lutus > http://www.arachnoid.com > > ------=_Part_28766_25619902.1163875542740--