![]() |
how do i use s3270/x3270 for scripting
I'm trying to write a script which will (upon completion), navigate through records maintained on an IBM mainframe using a tn3270 terminal, and scrape said records into html files for later manipulation.
I've read http://x3270.bgp.nu/s3270-man.html and http://x3270.bgp.nu/x3270-script.html The latter states: Quote:
By that definition, the following should work: Code:
connect(L:ssl3270.myhost.org:2023) \However, when i call the above using the script() function in s3270, the script prints to stdout, but the actions are not executed as expected. For example: Code:
(NOTICE: I've shortened the script for example's sake)I'm not sure what i am doing wrong. Can someone give me an example script that works? Something simple that depicts how i can use something like bash, perl, or python to send commands to this application and navigate through screens. Thanks in advance |
bash
So, i worked out how to do this in bash; though, i don't like the result.
Code:
#!/bin/bashwhile x3270if is nice, i reckon i expected a simpler solution...something easier to use with a language's built-in functionality. What would i do with perl? Hopefully not make a call to system() each time i want to input data. Is there a way to treat the terminal connection as a file handle and just send commands to it via print()? |
If you're keen on doing this in Perl, ask the gurus over at http://www.perlmonks.org/
|
Thanks
Chris,
Thank you for the excellent referral. I was on the right track to my answer in a few minutes... Using perl's IPC::Run module, i was able to pipe commands directly to the s3270 subprocess. Thus, the below is an example of x3270's peer script facility: Code:
#!/usr/bin/perlChris, Thanks again :) |
X3270 Script Example
I had similar problem and, although it's an old topic, I'd like to share a bourne shell script that worked out for me (based on example script from the author of x3270 (look at sourceforge).
Amazingly, you will find NOTHING when goggling "x3270 script example". Documentation could be better and is not focused toward dummies like me. Looks like nobody does x3270 scripting, or don't care to share. I did have a bad time trying to make this script work, hope you save your time. Enough talking, here it goes: Code:
#! /bin/bash |
yes, I Know, the thread is old. However the thread is good and there isn't out so much about tn3270.
So here are my experiences: I just compiled it on AIX using gcc-4.4.5-1 and used the following short ksh-script to test TSO availability using a ssl connection, without login: Code:
#!/bin/ksh |
I realize this is an old post but all the help I could google wasn't enough. I was stumped on this thing for a solid week so I am providing some sample code on how to better interact with s3270 using PHP.
#!/usr/bin/php //This is straight from the www.php.net/proc_open page. Just sets up an array for your pipes PHP Code:
PHP Code:
PHP Code:
//This function is the same as above except it will only wait about 10 seconds for a response and then continue running the script. PHP Code:
PHP Code:
|
doesn't work under WAMP
thank's to paleos for his exemple in PHP. It's work fine on a LAMP server but not under windows.
when i use ws3270.exe in command line ascii() return correct things, but in php all lines are umpty. I use the same php code on linux and on windows. does some one try it under windows ? |
| All times are GMT -5. The time now is 07:09 PM. |