Skip to content

Commit

Permalink
Create setenvironment.md
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschoen authored Aug 14, 2024
1 parent abf1819 commit 03960a6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions howto/setenvironment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# How to set an environment variable prior to calling a script using QSHEXEC or QSHBASH
It might be handy to be able to know if a particular job is calling a script such as a PHP, Python or other Bash script.

Here's a couple of options for setting environment variables for your scripts to pick up.

Add the environment variable from the IBM i CL or RPG job using the ADDENVVAR CL command or some other tool.

This example adds an env variable named CALLEDBY and then lists it for display by calling env from the PASE job.
```
ADDENVVAR ENVVAR(CALLEDBY) VALUE(QSHONI)
QSHONI/QSHBASH CMDLINE(env) DSPSTDOUT(*YES)
```

This example adds an env variable named CALLEDBY by calling the export command on the QSH/PASE command line and then lists it for display by calling env from the PASE job.
```
QSHONI/QSHBASH CMDLINE('export CALLEDBY=QSHONI;env') DSPSTDOUT(*YES)
```

0 comments on commit 03960a6

Please sign in to comment.