PIPE_CMD_LAST parameter (defines execution processing for the last command in a pipe) (UNIX only)
- Organization of this page
Format
#-adsh_conf PIPE_CMD_LAST {CURRENT|OTHER}
Description
This parameter specifies whether the last command in the pipeline in the current process is to be executed.
You specify CURRENT to update the contents of variables by using the last command in the pipeline and you want to use the updated contents in commands that follow the pipeline, as described in the following.
- Contents of job definition script:
typeset -i CNT=0 cat INFILE | while read STR do echo "$STR" let CNT=CNT+1 done echo "Line count is $CNT."
As a result, when the while statement terminates, the shell variable CNT stores the number of lines loaded by the read command (INFILE line count).
On the other hand, if you want use the last command in the pipeline to update the contents of variables but you want to revert to using the contents of the pre-update variables after the pipeline has terminated, specify OTHER (CBL_SYSUT1 and CBL_SYSUT2 are assumed to be common interface variables of CBLUAPx).
- Contents of job definition script:
CBL_SYSUT1=/file1 CBL_SYSUT2=/file2 CBLUAP1 cat INFILE | while read DIR do CBL_SYSUT1=`cmd1 y` CBL_SYSUT2=`cmd2 y` CBLUAP2 done CBLUAP3
In this case, when the while statement terminates, the shell variable CBL_SYSUT1 stores "/file1" and the shell variable CBL_SYSUT2 stores "/file2".
This parameter cannot be specified more than once in the same environment file. If it is specified more than once, an error message is output and the job terminates.
Operands
Notes
-
If this parameter is defined in both the system environment file and the job environment file, the definition in the job environment file takes effect.
Example
The examples below show the difference in the execution result when the input file and job definition script shown in the following are used to specify the PIPE_CMD_LAST parameter.
-
Example 1
Contents of job definition script:
STR="abcdefg" echo "ABCDEFG" | read STR echo $STR
Result output to the standard output (when CURRENT is specified in the PIPE_CMD_LAST parameter):
ABCDEFG
Result output to the standard output (when OTHER is specified in the PIPE_CMD_LAST parameter):
abcdefg
-
Example 2
Contents of job definition script:
A=1 echo "Hello World" | A=10 echo $A
Result output to the standard output (when CURRENT is specified in the PIPE_CMD_LAST parameter):
10
Result output to the standard output (when OTHER is specified in the PIPE_CMD_LAST parameter):
1
-
Example 3
Contents of the INFILE input file:
user1,500,Tomato user2,1000,Tomato user3,300,Lettuce user1,450,Cabbage user1,250,Orange
Contents of the job definition script:
typeset -i cnt=1 cat INFILE | grep user1 | while read NAME do if [ $cnt -ge 3 ]; then break fi echo "$cnt = $NAME" let cnt=cnt+1 done echo $cnt
The character strings from while to done are treated as the last command in the pipe.
Result output to the standard output (when CURRENT is specified in the PIPE_CMD_LAST parameter):
1 = user1,500,Tomato 2 = user1,450,Cabbage 3
Result output to the standard output (when OTHER is specified in the PIPE_CMD_LAST parameter):
1 = user1,500,Tomato 2 = user1,450,Cabbage 1