MuppetMaster
Technical User
I am attempting to author a class that interacts with a 3rd party application. The idea is that the 3rd party application receives and event, makes a request to an external Ruby script via STDIN/STDOUT, and then the external Ruby scripts issues commands via STDOUT and receives the response via STDIN.
I am able to receive the initial set of paramters that the application sends to my Ruby script via STDIN as follows:
(Any recommendations on building a Hash based on STDIN welcome.)
But, when I try to write a command:
Nothing appears to be returned to the 3rd party app and it 'hangs' waiting for the STDIN (only returns one line in this case as opposed to multiple at initialization).
If I run my script at the command line and interact with it there, STDIN/STDOUT work fine.
I am able to interact via STDIN/STDOUT with this same third party app via PHP. What am I doing wrong here?
I am able to receive the initial set of paramters that the application sends to my Ruby script via STDIN as follows:
Code:
protected
def getInitialParams()
@initial_params = Hash.new
$stdin.each do | line |
if line.length <= 1
break
end
line = line.split(":")
line[0] = line[0].rstrip
line[1] = line[1].to_s.strip
@initial_params["#{line[0]}"] = line[1]
end
@log.debug("initial params: #{@initial_params['agi_request']}")
end
(Any recommendations on building a Hash based on STDIN welcome.)
But, when I try to write a command:
Code:
def astCommand(command)
# Must be 'puts' to standard out as Asterisk requres a newline for commands
$stdout.puts command
@log.debug("After command puts")
result = $stdin.gets
return result
end
Nothing appears to be returned to the 3rd party app and it 'hangs' waiting for the STDIN (only returns one line in this case as opposed to multiple at initialization).
If I run my script at the command line and interact with it there, STDIN/STDOUT work fine.
I am able to interact via STDIN/STDOUT with this same third party app via PHP. What am I doing wrong here?