From: David Masover Date: 2008-07-23T13:44:56+09:00 Subject: Re: how do i open a terminal using ruby? On Tuesday 22 July 2008 03:54:46 Sebastian Hungerecker wrote: > Tim Pease wrote: > > Kernel.exec '/bin/bash', '-c', "ruby #{__FILE__} #{ARGV.join(' ')}" > > That won't open a terminal windows. It will simply execute bash which will > execute ruby, but if you weren't in a window before, you're still not. I don't think there's any standard way to open another terminal _window_, given that some platforms allow you to install many different kinds of terminals in the first place, and there simply is no way to do this consistently and cross-platform. On Windows, you could definitely call 'cmd'. On OS X, you're probably safe doing something with Terminal.app. But on Linux, what do you do? Gnome-terminal? Konsole? xterm? These are probably the most common to be installed, yet none are guaranteed... You could always implement your own terminal, in your own GUI -- but then you'll irritate people who have a favorite terminal, and would rather work from there. So this only really makes sense if you're just going to go whole-hog and use the GUI for everything. I think about all you can do here is detect that you're not running in a terminal, and if you're not, exit with an error. Most platforms make it easy enough to run a script in a terminal -- it's the default on Windows; OS X has a "script menu" that opens them in Terminal; and on typical Linux desktop environments, application launchers have a simple checkbox for "run in terminal", and double-clicking on a Ruby script should run it in a terminal anyway.