Class: S3270
- Inherits:
-
Object
- Object
- S3270
- Defined in:
- lib/racf/s3270.rb
Overview
Wrapper around s3270 daemon (x3270.bgp.nu/). S3270 is a scriptable emulator of a mainframe terminal
Constant Summary collapse
- DEFAULT_LOG_DIR =
File.("../../../log", __FILE__)
Instance Method Summary collapse
-
#action(command) ⇒ Object
Runs a s2370 action.
-
#close ⇒ Object
Closes the s3270 daemon and the telnet connection on its script port.
-
#complete_screen ⇒ Object
Returns the content of a set of paginated screens.
-
#initialize(host = "127.0.0.1", host_port = "3270", verbose = false, script_port = "3003", telnet_timeout = 30) ⇒ S3270
constructor
A new instance of S3270.
-
#screen ⇒ Object
Returns the current screen of the terminal.
-
#string_action(command) ⇒ Object
Puts a string command in the screen and press enter.
Constructor Details
#initialize(host = "127.0.0.1", host_port = "3270", verbose = false, script_port = "3003", telnet_timeout = 30) ⇒ S3270
Returns a new instance of S3270.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/racf/s3270.rb', line 9 def initialize(host="127.0.0.1", host_port="3270", verbose=false, script_port="3003", telnet_timeout=30) @host = host @host_port = host_port @script_port = script_port @verbose = verbose @telnet_timeout = telnet_timeout open_connection register_exit_hook end |
Instance Method Details
#action(command) ⇒ Object
Runs a s2370 action
22 23 24 25 26 27 28 |
# File 'lib/racf/s3270.rb', line 22 def action(command) # TODO check standarderror # From the x3270-script manual page (http://x3270.bgp.nu/x3270-script.html): # " If an error occurs in processing an action, the usual pop-up # window does not appear. Instead, the text is written to standard output." @connection.cmd(command) end |
#close ⇒ Object
Closes the s3270 daemon and the telnet connection on its script port
40 41 42 43 |
# File 'lib/racf/s3270.rb', line 40 def close self.action("quit") @connection.close end |
#complete_screen ⇒ Object
Returns the content of a set of paginated screens
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/racf/s3270.rb', line 53 def complete_screen screen, has_next_page = while has_next_page self.action("enter") next_screen, has_next_page = screen << "\n#{next_screen}" end screen.strip! screen.sub!(/\*\*\*$/, '') screen.strip! || screen end |
#screen ⇒ Object
Returns the current screen of the terminal
47 48 49 |
# File 'lib/racf/s3270.rb', line 47 def screen self.action("ascii") end |
#string_action(command) ⇒ Object
Puts a string command in the screen and press enter
32 33 34 35 |
# File 'lib/racf/s3270.rb', line 32 def string_action(command) self.action("string(\"#{command}\")") self.action("enter") end |