Solved

Iseries Automation

Posted on 2010-11-19
6
1,836 Views
Last Modified: 2013-11-10
So here is my dilema.
I am workoing with the i5 and would like to be able to automate the mundane tasks, like dspsyssts,mimix out put, move jobs from one q to another, and do scheduled saves and record the save times in excel.
I have dove into the siimplistic looking scripts that are created when recording a macro.
However, I would like to be able to create one of two ideas.
a.) Be able to create a VBscript macro that start the 5250(Already can get it started) then either acces the macro bar to set off recorded macros. (As I can then make timed cmdlets  to be started by windows for each process) Or directly run the macro from the /private folder and have it perform on the 5250.
or
b.) Create scripts inside the iSeries that will do the above tasks and be able to document the work that was done.

So cut and dry what I am looking for is a way to call the emulator,log in,call the recorded macro,Paste the results into an excel file.
Of cource error detection and what not would be nice if someone has a canned script already, but i can do that leg work when it comes time. Thanks for reading.
0
Comment
Question by:JTroyMills
  • 3
  • 2
6 Comments
 
LVL 34

Accepted Solution

by:
Gary Patterson earned 500 total points
ID: 34178638
Most of what you want to do would traditionally be handled by smart use of CL commands, writing CL programs on the AS/400, coupled with job scheduling.  This is the "built-in" interface for operational and administrative "scripting" on the AS/400.  CL offer robust error handling capabilities, too.

It is really tough to reliably script operations and do effective error handing through macro-type functions.  Lots of fussy little details like making sure the right window has focus, dealing with the possibility that Windows has popped up a message about something (you don't want your critical backup to fail or the system not to get restarted because your Antivirus program popped up a window unexpectedly and interrupted your macro, right?)

Plus, it is Windows.  What happens when it decides to spontaneously lock up or reboot, or your emulation session crashes, or an automatic update screws something up.

Much better to use the AS/400's designed-in automation interface:  CL Programs and Job Scheduling.

A simple example of automation:

If you need to save a library at 2am every day, you could just add the required SAVLIB command to the job scheduler using the ADDJOBSCDE command.

The SAVLIB command's OUTPUT, OUTFILE, OUTMBR, and INFTYPE parameters allow you to log information about the save to an output file.  You can download this log file into Excel using a Client Access File Transfer any time you need it.

If you need to perform a more complex series of steps, then you'd write a CL program, for example, to:

Send a message to all users that the system is going down for backups
End the QINTER subsystem
Wait 10 minutes for the subsystem to end (or even more sophisticated, monitor for the Subsystem Ended message)
Perform a series of SAVxx operations, logging information about each save to a file.
Restart the QINTER subsystem

And then schedule the CL program to run at a specific time on specific days using ADDJOBSCDE.

You can get more sophisticated and add code that generates entries into a log file (which you can later download into Excel if you want).  For example, if you create a simple table called OPSLOG (STRSQL - CREATE TABLE command) that has one column that is 500 bytes wide, this command can be used to write a log entry:

CALL QZDFMDB2 ('INSERT INTO OPSLOG VALUES(''Log entry goes here.'') ')

The Information Center has lots of information on CL Programming, and there are tons of good books and tutorials on the subject.  Google "CL Programming" for links and more.  To find version=specific information, Google 'CL Programming V5R4", for example.

You'll also find it a lot easier to get AS/400-specific help with CL programming questions, since that is the supported and most widely-used automation interface for the AS/400.

- Gary Patterson
PGM



SNDBRKMSG ...

DLYJOB 600

ENDSBS QINTER

DLYJOB 600

SAVLIB ...

SAVOBJ ...

SAVCFG ...

STRSBS QINTER



ENDPGM

Open in new window

0
 

Author Comment

by:JTroyMills
ID: 34193484
Thanks for the advice.
What i am trying to do is hybrid the .mac if you will but I keep running into errors when coding it.
I DIM out my variables but every time I try to instantiate WshShl = WScript.CreateObject("WScript.Shell")
I get the error undefined variable "Wscript"
?
Here is the code I am trying to do

Why am i getting the WScript not defined ?
Also to notate everything, I did not even have to define the Reply1 variable it just took it ?
sub subSub1_()



   autECLSession.autECLOIA.WaitForAppAvailable

   

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys ""

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[tab]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys ""

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[enter]"

   

   

   

   autECLSession.autECLPS.WaitForAttrib 20,6,"00","3c",3,10000



   autECLSession.autECLPS.WaitForCursor 20,7,10000



   autECLSession.autECLOIA.WaitForAppAvailable

   

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "dspsyssts"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[enter]"

   

   autECLSession.autECLPS.WaitForAttrib 1,1,"20","3c",3,10000



   autECLSession.autECLPS.WaitForCursor 1,1,10000



   autECLSession.autECLOIA.WaitForAppAvailable

   

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[right]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[down]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[down]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[down]"

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[down]"

   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark right]"



   autECLMacro "[mark left]"



   autECLMacro "[edit-copy]"



   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[pf3]"

   

   autECLSession.autECLPS.WaitForAttrib 20,6,"00","3c",3,10000



   autECLSession.autECLPS.Wait 2859 



   autECLSession.autECLOIA.WaitForAppAvailable

   

   autECLSession.autECLOIA.WaitForInputReady

   autECLSession.autECLPS.SendKeys "[pf3]"

end sub

Dim WshShl

Reply1 = inputbox("Test Input")

if Reply1 = "yes" then

msgbox("Everything is Working")

End if



Set WshShl = Wscript.CreateObject("WScript.Shell")

Open in new window

0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34197782
The "Wscript" object is the root object of the Windows Script Host object model.  It is only meaningful or useful when you are running in that environment (a VBS script that is started with the cscript command, for example), and you are not.

http://blogs.msdn.com/b/ericlippert/archive/2003/10/08/53175.aspx

If this is a Client Access macro, then you're running in VBA, so you'll need to use object models and methods that are available in that environment.

Perhaps you want to use Shell:

http://www.mvps.org/dmcritchie/excel/shell.htm

- Gary Patterson

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:JTroyMills
ID: 34201051
It may sound silly but what I am trying to do for the sake of time is create a custom script out of the iSeries Macro.
Basically record the functions that I want done, copy the text that is in the windows, echo it to a msg box for retention of info, verify that the info is what I wanted by comparing against a known good sample, emailing me if it is not with what was inputted, if it is the info I need paste it into excel to be reviewed at the end of the day.

So with that said, would VBA thorough the means of shell be able to do this for me ?
If so I will pour through Shell and figure out how to quickly make an outline that I can then dissipate as I learn more about CL for iSeries.
Thanks for sticking with me on this.,
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34201461
I understand what you're trying to do.  I've recorded macros and used them as starting points for scripts many times in many environments.

The VBScript in Client Access macros isn't really VBA, but I'm pretty sure it isn't running in the Windows Script Host (WSH) environment.   It apparently runs under an internal VBScript processor in Client Access.

What does this mean to you?  

It means that you can't directly use anything the depends on the WSH object model.  So if the VBScript code that you find has references to WSH objects, you can't use it in a CA VBScript macro:

http://msdn.microsoft.com/en-us/library/a74hyyw0%28VS.85%29.aspx

- Gary Patterson

0
 
LVL 16

Expert Comment

by:theo kouwenhoven
ID: 34204186
Try the program AUtoHotkey as macro tool, this is a Windows macro and will be cross application.
I tried it a while ago and thought it was awful and a waste of time.
Until I needed it a couple of weeks ago and started to study more detailed on the tool......
It's GREAT, but it takes some time to investigate how it works,

It has a build-in recorder, but also a macro editor.....

And another good thing is..... "It's Free" :-)

http://www.autohotkey.com/

Let me know what you think of it

GoodLuck
Murph
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now