B
bjornms
Hi
I'm trying to create a simple ruby script, which forks mplayer and
afterwards it stays in a while loop which blocks on gets (this is to
get keyboard input). I start this script from a terminal (linux). When
i start it, it forks mplayer and the focus is on mplayer now. If i
press some keys on my keyboard these are send to mplayer.
Is there a solution to get focus on the terminal/script again (without
user interaction) after i started mplayer? Or another solution to get
keyboard commands into my script?
For some more information i included my program. The client is the one
i'm talking about. The server sends the data via netcat to the client.
It is the beginning of something you might call a pvr (personal video
recorder).
Thanks in advance,
By the way this is my first ruby program (used to program c++/c#)
== pvr_client.rb ==
#!/usr/bin/ruby -w
require 'soap/rpc/driver'
class UI
def initialize
@driver = SOAP::RPC:
river.new('http://localhost:8888/',
'urn:mySoapServer')
@driver.add_method('startstream', 'toip');
fork do
exec('nc -l -p 5000 | mplayer -')
end
@driver.startstream('hoi')
end
def getInput
while( command = gets ) do
puts command
end
end
end
ui = UI.new
ui.getInput
== pvr_server.rb ==
#!/usr/bin/ruby -w
require 'soap/rpc/standaloneServer'
class MyServer < SOAP::RPC::StandaloneServer
def initialize(*args)
super
add_method(self, 'startstream', 'toip');
end
def startstream(toip)
fork do
puts 'start streaming'
exec('cat piet.mpg | nc localhost 5000')
end
end
end
server = MyServer.new('CoolServer', 'urn:mySoapServer', 'localhost',
8888)
trap('INT') { server.shutdown }
server.start
I'm trying to create a simple ruby script, which forks mplayer and
afterwards it stays in a while loop which blocks on gets (this is to
get keyboard input). I start this script from a terminal (linux). When
i start it, it forks mplayer and the focus is on mplayer now. If i
press some keys on my keyboard these are send to mplayer.
Is there a solution to get focus on the terminal/script again (without
user interaction) after i started mplayer? Or another solution to get
keyboard commands into my script?
For some more information i included my program. The client is the one
i'm talking about. The server sends the data via netcat to the client.
It is the beginning of something you might call a pvr (personal video
recorder).
Thanks in advance,
By the way this is my first ruby program (used to program c++/c#)
== pvr_client.rb ==
#!/usr/bin/ruby -w
require 'soap/rpc/driver'
class UI
def initialize
@driver = SOAP::RPC:
'urn:mySoapServer')
@driver.add_method('startstream', 'toip');
fork do
exec('nc -l -p 5000 | mplayer -')
end
@driver.startstream('hoi')
end
def getInput
while( command = gets ) do
puts command
end
end
end
ui = UI.new
ui.getInput
== pvr_server.rb ==
#!/usr/bin/ruby -w
require 'soap/rpc/standaloneServer'
class MyServer < SOAP::RPC::StandaloneServer
def initialize(*args)
super
add_method(self, 'startstream', 'toip');
end
def startstream(toip)
fork do
puts 'start streaming'
exec('cat piet.mpg | nc localhost 5000')
end
end
end
server = MyServer.new('CoolServer', 'urn:mySoapServer', 'localhost',
8888)
trap('INT') { server.shutdown }
server.start