SHELLEXECUTE stage v1.0

Pipelines v1.6

 

Purpose, Operands, Streams used, Usage notes, Examples, See also

Home

 

Syntax

 
                           _WAIT_________
                   _CMD_  |_SYNCHronous__|  _MAXERRor_MAX_INT____
>>__SHELLexecute__|_____|_|______________|_|_____________________|_ _________ _________><
                  |_EXE_| |_NOWAIT_______| |_MAXERRor_errorlevel_| |_command_|
                  |_PRG_| |_ASYNCHronous_|
 

Purpose

 

Use the SHELLEXECUTE stage to execute the specified command.

 

SHELLEXECUTE launches the specified process and begins reading records from that process’ STDOUT and STDERR streams. Records which are read from that process’ STDOUT stream are written to the primary output stream and records which are read from that process’ STDERR stream, are written to the secondary output stream, if it is connected.

 

Operands

 

    

CMD

specifies that command is a DOS or system shell command. This is the default.

 

    

EXE

PRG

specifies that command is an executable program.

 

    

WAIT

SYNCHronous

specifies that SHELLEXECUTE will wait for the command process to terminate before reading the next record from its primary input stream. This is the default.

 

    

NOWAIT

ASYNCHronous

specifies that SHELLEXECUTE will not wait for the command process to terminate, SHELLEXECUTE will read the next record from its primary input stream immediately.

 

    

MAXERROR

specifies the maximum allowed process returncode.

 

 

_MAX_INT_

is the maximum defined integer that is supported by Pipelines. This is the default.

 

errorlevel

is an unsigned integer which specifies the highest acceptable returncode which indicates that the process has completed successfully. A returncode that is higher than this defined maximum; will cause the SHELLEXECUTE stage to terminate with an error returncode.

 

    

command

specifies a DOS/system shell command or program to launch.

 

Streams used

 

The following streams are used by the SHELLEXECUTE stage:

 

Stream

Action

 

 

Primary input stream

SHELLEXECUTE reads records from its primary input stream and uses each as the command line argument for the specified process.  

Primary output stream

SHELLEXECUTE reads records from the process’ STDOUT and STDERR output streams and writes them to its primary output stream and secondary output stream, if it is connected.

 

Usage notes

 

     1)

SHELL does not delay the records.

 

     2)

When the WAIT or SYNCHronous keyword is specified; SHELLEXECUTE will wait for the command process to terminate before reading the next record from its primary input stream. This is the default

 

     3)

If you have Powershell installed on your machine; you can execute Powershell commands and scripts from within a pipeline, consider the following example, which selects only SVCHOST system process entries from the command output:

 

pipe (endchar ?)

     shell powershell ps

     | a: drop 3

     | locate anycase w-1 /svchost/

     | b: faninany

     | cons

     ?

     a:

     | take *

     | b:

 

The pipeline produces the following output:

 

06/07/2009 21:09:42 begin..

 

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName

-------  ------    -----      ----- -----   ------     -- -----------

    139       5     3280       4852    56     0.12    488 svchost

    291      24    10032       9544    71     1.14   1648 svchost

    120       5     1872       4312    40     0.14   2036 svchost

06/07/2009 21:09:43 end..(rc:0)

Press ENTER to close...

 

     4)

SHELLEXECUTE cannot anticipate the value or meaning of the returncode that is passed back by a third-party process and this includes DOS, system shell and Powershell commands. Pipelines operates on the principle that a zero returncode indicates the success of a process and any other returncode; indicates failure. This assumption will of course cause problems for a pipeline which uses the SHELLEXECUTE stage command when calling a process which does adhere to this standard. As a rule; you should check the documentation of the target process to determine the highest acceptable returncode which indicates that the process has completed successfully; so that you can be sure that the SHELLEXECUTE stage is safe to continue. As the process may or may not provide a message or description of why it failed on either of its output streams; Pipelines only provides the terminating returncode in its output messages.

 

It is not possible to predict the order in which records are read from the target process’ STDOUT and STDERR streams. Pipelines cannot anticipate the order in which records are produced by a third-party process and as such the SHELLEXECUTE stage command will only produce output records as and when they become available. SHELLEXECUTE reads records from the process’ STDOUT stream and writes them to its primary output stream, whilst reading records from the process’ STDERR stream and writes them to its secondary output stream, if it is connected.

 

     5)

If the SHELLEXECUTE stage discovers that its primary output stream is not connected; SHELLEXECUTE stops reading output records from the process’ STDOUT stream. Similarly, if the SHELLEXECUTE stage discovers that its secondary output stream is not connected; SHELLEXECUTE stops reading output records from the process’ STDERR stream.

 

     6)

SHELLEXECUTE verifies that its secondary input stream is not connected and then begins execution.

 

Examples

 

Using SHELLEXECUTE

 

See also

 
CALLPIPE, CONSOLE, IN, OUT, RUNPIPE
 

History of change

 

None.