Coder Social home page Coder Social logo

tn3270lib's Introduction

TN3270 Python Library (BETA)

This library is a pure python implemnation of a TN3270e emulator. To test this library you can issue the command python tn3270lib.py <hostname> <port>.

This library also implements IND$FILE file transfering.

To connect to a mainframe and log on:

>>> import tn3270lib
>>> tn3270 = tn3270lib.TN3270()
>>> host = "192.168.32.70"
>>> port = 23
>>> tn3270.initiate(host, port)
True
>>> data = tn3270.get_screen()
>>> print data
z/OS V1R13 PUT Level 1209                          IP Address = 10.10.0.13
                                                   VTAM Terminal =

                        Application Developer System
                                 //  OOOOOOO   SSSSS
                               //  OO    OO SS
                       zzzzzz //  OO    OO SS
                         zz  //  OO    OO SSSS
                       zz   //  OO    OO      SS
                     zz    //  OO    OO      SS
                   zzzzzz //   OOOOOOO  SSSS

                   System Customization - ADCD.Z113H.*



 ===> Enter "LOGON" followed by the TSO userid. Example "LOGON IBMUSER" or
 ===> Enter L followed by the APPLID
 ===> Examples: "L TSO", "L CICSTS41", "L CICSTS42", "L IMS11", "L IMS12"
>>> tn3270.send_cursor("TSO")
>>> tn3270.get_all_data()
>>> tn3270.send_cursor("margo")
>>> tn3270.get_all_data()
>>> tn3270.send_cursor("secret")
>>> tn3270.get_all_data()
>>> data = tn3270.get_screen()
>>> print data
ICH70001I PLAGUE   LAST ACCESS AT 12:15:24 ON TUESDAY, SEPTEMBER 13, 2016       
IKJ56455I PLAGUE LOGON IN PROGRESS AT 12:17:25 ON SEPTEMBER 13, 2016            
IKJ56951I NO BROADCAST MESSAGES                                                 
*****************************************************************               
*                                                               *               
*     WELCOME TO                                #               *               
*                                               ##              *               
* #######  ######## ########   ###### #######   ###  ##         *               
*  ###  ##  ###      ###      ###      ##   ##  #### ##         *               
*  ###  ##  #######  #######  ###      ##   ##  #######         *               
*  ###  ##  ###      ##       ###      ##   ##  ### ###         *               
*  ######   #######  ##        ######   #####   ###  ##         *               
*                                                     #         *               
*                                                               *               
*                                         A B.U.M. MAINFRAME    *               
*****************************************************************               
                                                                                
READY                                                                           
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                

>>> 

Debugging

To help understand all the tn3270 commands and the various stages of the connection debugging is included with this library. To enable simple debugging use tn3270.set_debuglevel(1) to increase the verbosity you can set debugging to level 2 tn3270.set_debuglevel(2) but it explains every tn3270 command and push to the buffer but can aid in understanding what it happening behind the scenes.

LU Setting

This library also supports selecting a specific LU. Use the function set_LU("LUNAME") to set the LU you want to use priot to initiating a connection.

File Transfer

With this library you can now send and receive files/datasets EBCDIC to ASCII translation is done by z/OS if you use the get/send_ascii functions

To send file you use the methods send_ascii_file/send_binary_file. Note that each method requires a destination dataset and a local file you wish to send.

>>> tn3270.send_ascii_file("'ibmuser.jcltest'","/home/dade/awesome.jcl")
>>> tn3270.send_binary_file("'ibmuser.exec'","/home/dade/a.out")

To receive files you can use the methods get_ascii_file/get_binary_file. As with sending a file you establish the from dataset and the file you wish to save to locally:

>>> tn3270.get_ascii_file("'ibmuser.jcltest'","/home/dade/new.jcl")
>>> tn3270.get_binary_file("'ibmuser.asm(compiled)'","/home/dade/compiled.asm")

Thanks

This library wouldn't have been possible with x3270 and its great -trace feature, RFC 2355, RFC 1576, the python telnet library and various stackoverflow tips!

tn3270lib's People

Contributors

mainframed avatar bigendiansmalls avatar

Stargazers

Alex Kwiatkowski avatar Joe Farjallah avatar Dmitry Nikolaev avatar  avatar Nico Einsidler avatar Rafael Pala avatar Tiago Rodrigues avatar Mike Großmann avatar  avatar Alin Climente avatar Leandro Gabriel López avatar Igor Bojovic avatar C For C's Sake avatar WLY avatar  avatar Petr Plavjaník avatar Sam Knutson avatar  avatar Teodor Cimpoesu avatar Noirox avatar Howard Wang avatar Luis Alberto avatar Russ Herrold avatar Rafael Sotero Rocha avatar  avatar Robert avatar Samuel Bishop avatar Parsia Hakimian avatar  avatar Peter Halsted avatar Justin Albertyn avatar Mohit Sethi avatar  avatar Raymond Phillips avatar unbaiat avatar  avatar  avatar David Davidson avatar  avatar

Watchers

Russ Herrold avatar Mike Großmann avatar James Cloos avatar  avatar Fairiestoy avatar Luis Alberto avatar C For C's Sake avatar Zed Security avatar  avatar  avatar

tn3270lib's Issues

Python 3.7.1

Looks like it is not working with Python 3.7.1

This Utility is not working for me.

I am getting this exception

Traceback (most recent call last):
  File "C:/Users/a595080/Desktop/MAUI-PlaceOrder/MAUI-PlaceOrder/codebase/scripts/fidelity_libs/3270.py", line 13, in <module>
    test()
  File "C:/Users/a595080/Desktop/MAUI-PlaceOrder/MAUI-PlaceOrder/codebase/scripts/fidelity_libs/3270.py", line 9, in test
    tn3270.initiate(host, 23)
  File "C:\Users\a595080\Desktop\MAUI-PlaceOrder\MAUI-PlaceOrder\codebase\scripts\fidelity_libs\tn3270lib.py", line 474, in initiate
    self.telnet_data = self.recv_data()
  File "C:\Users\a595080\Desktop\MAUI-PlaceOrder\MAUI-PlaceOrder\codebase\scripts\fidelity_libs\tn3270lib.py", line 383, in recv_data
    buf = self.sock.recv(256)
socket.timeout: timed out

Send Tab character

Howdy,
Im having some issues with the login part.

tn3270.send_cursor("margo")
tn3270.get_all_data()
tn3270.send_cursor("secret")
tn3270.get_all_data()

When i attempt this, this ineviatbely ends with secret being on the screen, but username having disappeared...

           Your USERID     ===>

           Your PASSWORD   ===> Secret

           New PASSWORD    ===>
           Verify PASSWORD ===>

GSSN100E USERID required and has not been supplied.

Is there a better way to tab etween fields? eg send cursor, send tab, send cursor?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.