Genie Macro for Users without Command Line Access



In some situations, certain users are not allowed to use the command line in 5250. These limited capabilities are related to the user profile and block command line access. The users will still see the command line, but when they try to use this, a message stating that the user cannot run commands will appear. Because these users do not have command line access, they cannot run commands using a regular Genie macro. However, you may want your Genie macro to be able to run commands (i.e. CALL MYPGM) to launch a program, even for users who don't have access to the command line. For this example, we will be explaining how to accomplish this in relation to Atrium and setting up a Genie macro as a menu option.  

One solution for this is to create your own "launcher" command. When you create and compile your own commands on IBM i, you have the option to make the command available to users with "limited capabilities". If you create a command that allows this, then users that do not have access to the command line will still be able to run a command. This documentation explains the steps needed in order to create the command as well as setting up the proper Genie macro in Atrium in order to use this.

Steps:

1) Create the CL Program

First, you will need to create a CL program for this. In this case, the name of the CL program is "LAUNCHER". See below:

PGM PARM(&CMD &PWD) DCL VAR(&CMD) TYPE(*CHAR) LEN(100) DCL VAR(&PWD) TYPE(*CHAR) LEN(32) IF (&PWD *EQ 'OyI0MNr5vcW6bhx4m1ad') DO CALL PGM(QCMDEXC) PARM(&CMD 100) MONMSG CPF0000 ENDDO ENDPGM

The purpose of the CL program is to allow for running any command, provided that the user knows the password. It doesn't matter what you use for the password here, but we recommend using a random string that you can easily copy and paste into the Atrium Genie macro, but that users will not be able to easily guess. 

You should compile the CL program using the following: CRTCLPGM PGM(QGPL/LAUNCHER). 

2) Create the Command Interface

In order to make this available to limited users, you will need to create a command. We chose to name the command "LAUNCHER" as well. See below: 

CMD PROMPT('Launch 5250 Command') PARM KWD(CMD) TYPE(*CHAR) LEN(100) MIN(1) + EXPR(*YES) CASE(*MIXED) DSPINPUT(*YES) + PROMPT('Command to run') PARM KWD(PWD) TYPE(*CHAR) LEN(32) MIN(1) + EXPR(*YES) CASE(*MIXED) DSPINPUT(*PROMPT) + PROMPT('Launcher password')

The above code will create the "LAUNCHER" command. This command will include two parameters: the command that you want to run and the password needed in order to run the command. 

You should compile the command using the following: CRTCMD CMD(QGPL/LAUNCHER) PGM(QGPL/LAUNCHER) ALWLMTUSR(*YES). Because this is compiled with ALWLMTUSR(*YES), it can be run by users that wouldn't typically have command line access. 

3) Set up the Genie Macro in Atrium

After you've set up the CL program and the "LAUNCHER" command, you can run this command from any command line in your Atrium Genie macro. 

First, you need to create a screen definition (or multiple, if needed) to find a screen with a command line. Below is an example for detecting the 'Main' screen with the command line: 

For this 'Main' screen, at the command line, you will want to write the value "?LAUNCHER" and then press the "ENTER" key. The question mark ( ? ) in the command line will cause it to prompt the LAUNCHER command. So, the actions for your 'Main' screen would look like this: 

Next, you will need to create a screen definition to detect the string "Launch 5250 Command (LAUNCHER)". This will detect the screen for the LAUNCHER command and will prompt for the 2 parameters described above in the command's code. We named this screen "Detect Launch Screen" and detected it as shown below: 

When this screen is found, you will want to insert the password into the password field by hard-coding it into the macro. Because this macro will have the correct password hard-coded in it, it can run any command. Since the users do not know the password, and it is never shown to them since the macro isn't visible, only the macro will be able to run commands this way. You will also want to write a variable named "Command" into the command field, so that you can tell your macro which command to run when setting this up in Atrium. Your actions for this screen should look like: 

So, as a whole, your Genie macro should be set up as shown below: 

Notice that we have also added an action to our Genie macro to bypass the "Display Program Messages" screen. This may be necessary in order for your macro to work properly. This is explained more in-depth here. 

4) Test!

After setting up your Genie macro in Atrium, you can use your Atrium menu items to call this macro. Under the "Command" parameter (that you see when you are setting up this macro as a menu item) you can put any command here that you'd like. For example, you may want to have a menu item that calls WRKSPLF. This will run the "Work with All Spooled Files" command in Genie just by choosing the appropriate menu item in Atrium. Below is an example of how you might set up this Genie macro: 

If you need more information on adding a Genie macro to the Navigation Menu in Atrium, you can learn more about this by visiting the following page: Adding a Genie Macro to the Navigation Menu.