i want to open up a terminal from ruby if it was not executed in one.
so,
if not STDIN.isatty #Open up a terminal
end
do i have to use IO.popen? i would rather not because, i'm using linux
but this ruby script will also be executed on windows. how do i account
for when to use "gnome-terminal" and when to use "cmd"? then, how do i
write to that terminal window?
On Jul 21, 2008, at 6:08 PM, Philip Rutkowski wrote:
hi-
i want to open up a terminal from ruby if it was not executed in one.
so,
if not STDIN.isatty #Open up a terminal
end
do i have to use IO.popen? i would rather not because, i'm using linux
but this ruby script will also be executed on windows. how do i account
for when to use "gnome-terminal" and when to use "cmd"? then, how do i
write to that terminal window?
On Jul 21, 2008, at 6:08 PM, Philip Rutkowski wrote:
hi-
i want to open up a terminal from ruby if it was not executed in one.
so,
if not STDIN.isatty #Open up a terminal
end
do i have to use IO.popen? i would rather not because, i'm using linux
but this ruby script will also be executed on windows. how do i account
for when to use "gnome-terminal" and when to use "cmd"? then, how do i
write to that terminal window?
is there something easier?
thanks!!!
--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama
if not STDIN.isatty #Open up a terminal
end
[...]
is there something easier?
If I'm not mistaken, on Windows ruby scripts automatically open in a command
window. And most filemanagers on unix ask you whether to open a terminal when
clicking on an executable file. So I don't think there's any need to do what
you're trying to do.
if not STDIN.isatty #Open up a terminal
end
[...]
is there something easier?
If I'm not mistaken, on Windows ruby scripts automatically open in a
command
window. And most filemanagers on unix ask you whether to open a terminal
when
clicking on an executable file. So I don't think there's any need to do
what
you're trying to do.
HTH,
Sebastian
I have the same need. I have a script that runs in a terminal right
now, but I eventually want to make it gui (probably with Shoes) and I'll
need an option to click a button and open a command prompt (then run a
command in that command prompt and leave the prompt open for the user to
use).
I haven't even begun converting to the gui part yet though, so I haven't
put much thought into how I'm going to accomplish this. Oh yeah, and
this will need to be cross-platform, too, but it may just be a matter of
writing a slightly different program for each platform.
Check out Monkeybars (http://monkeybars.rubyforge.org/\) for GUI stuff. Combine that with Rawr and you should have a slick cross-platform GUI along with native .app/.exe files and/or a web start link. Monkeybars sits on JRuby, so you might be able to find some Java libraries to help you out along with your gems. A quick search for Java terminal stuff yielded JLine (http://jline.sourceforge.net/\). Of course, that's if the gem you had in mind isn't adequate for what you're doing.
···
On Jul 22, 2008, at 6:37 AM, James Dinkel wrote:
I have the same need. I have a script that runs in a terminal right
now, but I eventually want to make it gui (probably with Shoes) and I'll
need an option to click a button and open a command prompt (then run a
command in that command prompt and leave the prompt open for the user to
use).
I haven't even begun converting to the gui part yet though, so I haven't
put much thought into how I'm going to accomplish this. Oh yeah, and
this will need to be cross-platform, too, but it may just be a matter of
writing a slightly different program for each platform.
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.
···
On Tuesday 22 July 2008 03:54:46 Sebastian Hungerecker wrote: