I know I can do
system “ruby script.rb”
But I want to open a console to run it in.
Thanks.
T
I know I can do
system “ruby script.rb”
But I want to open a console to run it in.
Thanks.
T
On Sun, 2 Jul 2006 [email protected] wrote:
I know I can do
system “ruby script.rb”
But I want to open a console to run it in.
you mean a pty? check out ext/pty, there’s an example in there.
cheers.
-a
[email protected] wrote:
On Sun, 2 Jul 2006 [email protected] wrote:
I know I can do
system “ruby script.rb”
But I want to open a console to run it in.
you mean a pty? check out ext/pty, there’s an example in there.
I want a window to come up with a shell propmt (or dos on windows).
T.
[email protected] wrote:
But I want to open a console to run it in.
you mean a pty? check out ext/pty, there’s an example in there.
I want a window to come up with a shell propmt (or dos on windows).
you probably want something like
Thanks. It worked!!! Check out Ballyhoo balloon
T.
On Sun, 2 Jul 2006 [email protected] wrote:
you mean a pty? check out ext/pty, there’s an example in there.
I want a window to come up with a shell propmt (or dos on windows).
you probably want something like
fortytwo :~ > cat a.rb
require ‘rbconfig’
require ‘tempfile’
def console command
arch = Config::CONFIG[‘arch’]
unless arch =~ %r/win/i
tmp = Tempfile.new Process.pid.to_s
tmp << command
tmp << "\n"
tmp << "bash"
tmp << "\n"
tmp.close
begin
system "xterm -e 'bash -l -i #{ tmp.path }'"
ensure
tmp.close!
end
else
raise 'windoze'
end
end
console ‘date’
i’ll leave the windoze bit to you
regards.
-a
Windoze equivalent inserted below
On 7/1/06, [email protected] [email protected] wrote:
tmp << command tmp << "\n" tmp << "bash" tmp << "\n" tmp.close begin system "xterm -e 'bash -l -i #{ tmp.path }'" ensure tmp.close! end else
system "start cmd /k #{command}"
end
end
console ‘date’
Regards,
Sean
Beware that you’re technically detecting both windows and mac (darwin)
with /win/. You might want to check for win32 (or, i suppose, win64?)
instead.
James A. wrote:
Beware that you’re technically detecting both windows and mac (darwin)
with /win/. You might want to check for win32 (or, i suppose, win64?)
instead.
Thanks. I’ll change that. How does one do this on mac btw?
T.
On Jul 2, 2006, at 2:02 PM, [email protected] wrote:
Thanks. I’ll change that. How does one do this on mac btw?
- h.h. the 14th dali lama
Eh, yeah but it’s not ideal (You’ll have to wait for X11 to start
usually, which it may or may not do automatically, I’m not sure. i
think it might if opened via the Finder but not from the command
line).
What I would do is
IO.popen(“osascript”, “w”) do |io|
io.puts <<APPLESCRIPT
tell Application “Terminal”
activate
do script “#{command_here}”
end tell
APPLESCRIPT
end
This has the advantage of not opening a new instance of terminal if
one is already open, (but it will if necessary) and not requiring the
user to a) have X11 installed and b) have it running.
Logan C. wrote:
activate
do script “#{command_here}”
end tell
APPLESCRIPT
endThis has the advantage of not opening a new instance of terminal if
one is already open, (but it will if necessary) and not requiring the
user to a) have X11 installed and b) have it running.
Thanks. I added it to my balloon. Maybe it works?
http://balloon.hobix.com/ballyhoo
T.
On Mon, 3 Jul 2006 [email protected] wrote:
James A. wrote:
Beware that you’re technically detecting both windows and mac (darwin)
with /win/. You might want to check for win32 (or, i suppose, win64?)
instead.Thanks. I’ll change that. How does one do this on mac btw?
T.
the xterm command should work fine.
-a
On Jul 2, 2006, at 2:45 PM, [email protected] wrote:
io.puts <<APPLESCRIPT
Thanks. I added it to my balloon. Maybe it works?
http://balloon.hobix.com/ballyhoo
T.
Well, it doesn’t work but not because of terminals not opening. You
have a syntax error in the actual page
io.puts << APPLESCRIPT
should be
io.puts <<APPLESCRIPT # it’s a heredoc
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs