Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

How do i interact with a ibm 3270 mainframe?

by pedrosantos (Novice)
on Dec 14, 2009 at 02:56 UTC ( [id://812635]=perlquestion: print w/replies, xml ) Need Help??

pedrosantos has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks, Does anyone have code to make perl talk to a ibm 3270 mainframe?

So far ive read about sockets, copied and pasted code to connect, but i dont see anything from the server. i am

CLUELESS

.

in my job i have to connect 4 times a day to a QWS3270 terminal,(by hand), copy and paste a bunch of screens in a text file (by hand too) and finally make perl extract the usefull data.

i believe it MUST be perl who handles connecting to the server and capturing DATA without my intervention AND in a regular (automated) schedule...

Can anyone please help me?

Replies are listed 'Best First'.
Re: How do i interact with a ibm 3270 mainframe?
by keszler (Priest) on Dec 14, 2009 at 03:04 UTC

      Thx a lot for the support, i can telnet to the IBM mainframe; i went through links and ended up with the following code:

      use IO::Socket; my $sock = IO::Socket::INET->new( Proto => 'TCP', PeerAddr => '161.196.25.2', PeerPort => '23', ) or die "Unable to create socket: $!\n"; #while ( <$sock> ) { print } @line=<$sock>; print @line;

      Unfortunately, as i run this pl, the machine just "hang up", till CTRL+C is pressed.

      Any examples using Net::elnet, Expect ?

      .

      Regards.

        Yeah, no sense in using raw sockets when Net::Telnet has already been written and thoroughly tested.

        I don't have any examples easily available - I'd have to strip out irrelevant and proprietary code - but the EXAMPLES section of the docs is a good starting point.

Re: How do i interact with a ibm 3270 mainframe?
by salva (Canon) on Dec 14, 2009 at 08:43 UTC
    You can use s3270. It is a special version of the x3270 emulator specifically designed to be used from scripts.
      Of course. I do that all the time at my company (no telnet access for me)
      #!/usr/bin/perl use IPC::Open2; use POSIX ":sys_wait_h"; open PASS, "< /etc/passgmc"; while (<PASS>) { chop ($_);($user,$password)=/(.*)\:(.*)/;} close PASS; if (length($user)<8) {$user.="\\t";} select((select(STDOUT), $|=1)[0]); $pid = open2(*CHILD_OUT, *CHILD_IN, 's3270 myhost.mycompany'); print CHILD_IN "Ascii\n"; while (<CHILD_OUT>) { #print $_; last if /ok/; } print CHILD_IN "String $user$password\\n\n"; while (<CHILD_OUT>) { #print $_; last if /ok/; } print CHILD_IN "Ascii\n"; while (<CHILD_OUT>) { #print $_; last if /ok/; } print CHILD_IN "String heythisisacommand\\n\\nLGCA\\n\n"; while (<CHILD_OUT>) { #print $_; last if /ok/; } #let's send some input to the app while (<>) { $inicio=time; chop $_; $myinput=$_; print CHILD_IN "String ".$myinput."\\t\\t\\t\\t\\tX\\n\n"; while (<CHILD_OUT>) { #print $_; last if /ok/; } print CHILD_IN "Ascii\n"; while (<CHILD_OUT>) { #let's look for something in the output if (/NOT FOUND/) { $k="K0000"; $desc="NOPE"; } if (/CODE..:.(K....).(.*)/) {$k=$1;$desc=$2;} last if /ok/; } print $myinput." ".$k." ".$desc."\n"; print STDERR $myinput." ".$k." ".$desc."\n"; #let's go to the previous screen if (not ($k eq "K0000")) { print CHILD_IN "String \\pa1\n"; while (<CHILD_OUT>) { #print $_; last if /ok/; } } # print CHILD_IN "\cD"; # print time-$inicio."\n"; } close CHILD_IN; close CHID_OUT; kill 9,$pid; waitpid $pid,0;
Re: How do i interact with a ibm 3270 mainframe?
by JSchmitz (Canon) on Dec 14, 2009 at 16:20 UTC
    The new Z10 mainframes run linux what's a few million bucks here or there - tell your boss it would easiest to replace the entire system = )

    There is a similar post about this here 611038 which provides some valuable info..however I like my first idea better = )
    Cheers

    Jeffery
Re: How do i interact with a ibm 3270 mainframe?
by jonadab (Parson) on Dec 16, 2009 at 08:30 UTC

    Oh, man, nostalgia rush. You're telling me there are still people using 3270 systems in 2009? That's extremely cool. I haven't connected to one of those things since gopher was in widespread use. I always liked tn3270 better than the garden-variety telnet, perhaps because the 3270 systems I had occasion to connect to made good use of available color capabilities; the telnet-based services I used, such as LOCIS, always felt drab in comparison.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://812635]
Approved by keszler
Front-paged by MidLifeXis
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-19 02:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found