Dreaded AS400 Automation!! Tamed?

Background: During process automation we face multiple challenges, multiple technologies, multiple constraints, limited tools, limited knowledge and off course very limited budget :).

Given if I want to automated my task, because of the above constrains we struggle a lot. One of the most dreaded of such areas I have seen is AS400. Although its share has been decreasing, but it just wont go away.

We were tasked with to automate such items to do some activities collect some data from i series systems and report back. So we started looking for out of the box opensource solutions (limited budget i told you).

We have seen multiple ways of doing that , Multiple off the shelf tools on the market(here), IBM i- series supports macros itself (here). We explored macros and they have some tremendous capability, that will be a blog for some other time though. Also another open source AS400 tool that supports almost everything that we need (here).

But all those did not support 3 basic things , It should be cheap, I should be able to login by itself and it should work in the background as a job, while I work(watch cat videos) on my system

So with the background of the way lets get on with it. We will be needing 1 full power-shell ISE, and x3270 downloaded fresh from here. Take a portable version so that its good for your PC health. We will also be using a new module for powershell Await (here). We are all done with ingredients. If you need you can open a AS400 public account here

To give a bit of detail , Await module allows us to run interactive commandlines via powershell. x3270 allows for AS400 automation. Let me give you the code, It will be self explanatory

#Import-Module await # in case needed 
#get-command -Module await # get await commands
Start-AwaitSession # Start automated session
Start-Sleep 1
Send-AwaitCommand "& 'D:\path\to\ws3270.exe' -model 3278-2 -port 23 pub400.com"
Start-Sleep 1
#Wait-AwaitResponse User # wait for "user" in the response
Start-Sleep 1
Send-AwaitCommand 'query(Cursor)' # query(Cursor) is a x3270 command details here
Start-Sleep 1
Wait-AwaitResponse 'ok'
Start-Sleep 1
Send-AwaitCommand 'string("AS400user")'
Start-Sleep 1
Wait-AwaitResponse 'ok'
Start-Sleep 1
Send-AwaitCommand 'movecursor(6,25)'
Start-Sleep 1
Wait-AwaitResponse 'ok'
Start-Sleep 1
Send-AwaitCommand 'string("AS400Password")'
Start-Sleep 1
Wait-AwaitResponse 'ok'
Start-Sleep 1
Send-AwaitCommand 'enter()'
Start-Sleep 1
Wait-AwaitResponse 'ok'
Start-Sleep 1
Send-AwaitCommand 'ascii()'
Start-Sleep 5
#Wait-AwaitResponse 'IBM i Main Menu'
Receive-AwaitResponse
Start-Sleep 1
Stop-AwaitSession

I have given you a basic script to get started make sure that we have gone through the scripting page for x3270 here. If you need anything I will be avalible here for your help.

Thats all folks until next time then

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

PACTF 2018 Writeup: AI

Fowsniff: 1

HIGH AVAILABILITY ARCHITECTURE WITH AWS CLI

📢Medium guide

Using Automation in HR — Gleematic A.I

Compare use Storyboard and use by code make constraints.

How to Attach Oracle Block Volume

IDO on Cronos network

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Ibrezm

Ibrezm

More from Medium

Schedule an EC2 instance

Service virtualization

Kata -> Repetation -> Habit -> Mastery

Repetition creates habits, and habits are what enable mastery. | Kata | @iSwamiK

2021 Year in Review: DevOps Consultant