From 03960a6aa5bc9149077d6a11a4b86dbec1e21313 Mon Sep 17 00:00:00 2001 From: Richard Schoen Date: Wed, 14 Aug 2024 13:19:57 -0500 Subject: [PATCH] Create setenvironment.md --- howto/setenvironment.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 howto/setenvironment.md diff --git a/howto/setenvironment.md b/howto/setenvironment.md new file mode 100644 index 0000000..2319112 --- /dev/null +++ b/howto/setenvironment.md @@ -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) +```