Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschoen authored Apr 28, 2024
1 parent d5e63cf commit e27049b
Showing 1 changed file with 86 additions and 2 deletions.
88 changes: 86 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,7 @@ Parameters can be delimited with double quotes if needed.

**RMVTMPSCR** - This option determines if the temporary IFS script file is auto-deleted after running. Normally the selection should be *YES to delete the temp file. Otherwise specify *NO if you are debugging for some reason. ***Default = *YES ***

**PROMPTCMD** - This option determines if the ```QSH``` command is prompted interactively for testing or review of the actual QShell command line with parameter values before running the command. Normally the selection should be *NO since prompting is only needed if testing. Specify *YES if you are debugging for some reason and want the QSH command to prompt on an interactive 5250 session before running. ***Default = *NO ***

**PROMPTCMD** - This option determines if the ```QSH``` command is prompted interactively for testing or review of the actual QShell command line with parameter values before running the command. Normally the selection should be *NO since prompting is only needed if testing. Specify *YES if you are debugging for some reason and want the QSH command to prompt on an interactive 5250 session before running. ***Default = *NO ***

# Using the QSHBASH CL command to call a bash command sequence

Expand Down Expand Up @@ -334,6 +333,91 @@ The command is a convenience wrapper that can be used to call a bash command wit

**PASEJOBNAM** - PASE fork thread job names. Set PASE_FORK_JOBNAME environment variable to set forked thread jobs to have a unique name other than: QP0ZSPWP which is the default. Set the value or *DEFAULT=QP0ZSPWP.

# Using the QSHBASHSRC CL command to call a bash script command sequence from a classic IBM i source member

The following example calls a bash source member QSHELL01 stored in source file QSHONI/SOURCE to run the ls command to list files for the /tmp directory:

```
QSHBASHSRC SRCFILE(QSHONI/SOURCE)
SRCMBR(QSHELL01)
CMDPARM(' ')
DSPSTDOUT(*YES)
LOGSTDOUT(*NO)
PRTSTDOUT(*NO)
DLTSTDOUT(*YES)
IFSSTDOUT(*NO)
IFSFILE('/tmp/log.txt')
IFSOPT(*REPLACE)
PRTSPLF(QSHEXECLOG)
PRTUSRDTA(*NONE)
PRTTXT(*NONE)
RMVTMPSCR(*YES)
PROMPTCMD(*NO)
```

Sample bash source member: ```QSHONI/SOURCE(QSHELL01)``` Type: TXT Text: Bash script to List Files in /tmp folder
```
cd /tmp
ls -l
```

# QSHBASHSRC command parms

**Overview** - This CL command can be used to run a bash command shell script from a classic source physical file member and log the results appropriately.

The use case would be for an app where you want to store your Bash/QShell/PASE/Python/PHP/Etc. scripts as part of your library source and execute those scripts directly from a source physical file.

```Stdout Logging Note:``` During execution, the CL command always creates a temporary outfile in library QTEMP that gets automatically populated with standard output (stdout) from the QSH/PASE command process that gets run. The temporary stdout output file name is: ```QTEMP/STDOUTQSH```. If the file already exists for a subsequent run of the command, the ```QTEMP/STDOUTQSH``` temporary file is automatically cleared before running so each run gets a fresh copy of ```QTEMP/STDOUTQSH```. The ```QTEMP/STDOUTQSH``` temp file gets created automatically always, even if none of the switches such as: ```DSPSTDOUT, LOGSTDOUT, PRTSTDOUT or IFSSTDOUT``` are specified.

**SRCFILE** - Source physical file where bash script is stored.

**SRCMBR** - Source member name where bash script is stored. Script is automatically copied to an IFS based temp file in IFS dir ```/tmp/qsh``` for execution. The IFS temp file is auto-deleted by default after it runs unless you specify *NO to the RMVTMPSCR parameter.

Changes to your script source members can be made usig via the SEU, RDi or VS Code editors.

**CMDPARM** - Command line parms to pass to the selected bash script that runs. If no parameters are needed simply pass ```' '``` for the CMDPARM value.

Parameters can be delimited with double quotes if needed.
```Ex: "parm1" "parm2" "parm3"```

**SETPKGPATH** - Add the IBM i Open Source Package path to PATH environment variable by calling QSHPATH command before running bash commands. Default = *YES.

**DSPSTDOUT** - Display the outfile contents. Nice when debugging.

**LOGSTDOUT** - Place STDOUT log entries into the current jobs job log. Use this if you want the log info in the IBM i joblog. All STDOUT entries are written as CPF message: **QSS9898**

**PRTSTDOUT** - Print STDOUT to a spool file. Use this if you want a spool file of the log output.

**DLTSTDOUT** - This option insures that the STDOUT IFS temp files get cleaned up after processing. All IFS log files get created in the /tmp/qsh directory.

**IFSSTDOUT** - Copy std output to an IFS file. Nice for aggregating log results to a file.

**IFSFILE** - IFS file for stdout results. Needs to be specified if IFSSTDOUT = *YES.

**IFSOPT** - IFS file option. *REPLACE = replace stdout IFS file. *ADD = Add to stdout IFS file.

**CCSID** - When using the iToolkit component for command access, I originally had some issues with CL commands not working correctly. However I don't currently remember exactly why. This may have been solved, however I recommend still passing a value of 37 unless you are in a non US country. If you set to `*SAME`, the CCSID will stay the same as your current job with no change.

**PRTSPLF** - This option holds the name of the spool file used when PRTSTDOUT = *YES. It's a nice way to customize the stdout log prints. ***Default = QSHBASHLOG***

**PRTUSRDTA** - This option holds the name of the spool file user data used when PRTSTDOUT = *YES. ***Default = *NONE ***

**PRTTXT** - This option holds the name of the spool file print txt to be used when PRTSTDOUT = *YES. ***Default = *NONE ***

**PRTHOLD** - This option determines if the spool file is held if one is generated when PRTSTDOUT = *YES. ***Default = *YES ***

**PRTOUTQ** - This option determines the output queue where the spool file will generated to when PRTSTDOUT = *YES. ***Default = *SAME ***

**OUTFILE** - Output physical file to receive STDOUT from the QSH/PASE command. Default file: ```QTEMP/STDOUTQSH``` This output file ```always gets created and populated```.

**MBROPT** - Output file option. Default: ```*REPLACE``` *REPLACE = replace outfile contents. *ADD = Add to outfile contents. Generally you should replace the file contents. If you want to append to a log file it's recommended to use the IFS output file option to write or append to an IFS file log. This is much more amenable to log readers or processors.

**PASEJOBNAM** - PASE fork thread job names. Set PASE_FORK_JOBNAME environment variable to set forked thread jobs to have a unique name other than: QP0ZSPWP which is the default. Set the value or *DEFAULT=QP0ZSPWP.

**RMVTMPSCR** - This option determines if the temporary IFS script file is auto-deleted after running. Normally the selection should be *YES to delete the temp file. Otherwise specify *NO if you are debugging for some reason. ***Default = *YES ***

**PROMPTCMD** - This option determines if the ```QSH``` command is prompted interactively for testing or review of the actual bash command line with parameter values before running the command. Normally the selection should be *NO since prompting is only needed if testing. Specify *YES if you are debugging for some reason and want the QSH command to prompt on an interactive 5250 session before running. ***Default = *NO ***

# Using the QSHCURL CL command to call a curl command sequence

The following example calls the curl command to download the google home page site contents to an IFS file. You only need to pass the parms after curl
Expand Down

0 comments on commit e27049b

Please sign in to comment.