Class ExecuteStreamCommand

java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.ExecuteStreamCommand
All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent, org.apache.nifi.processor.Processor

@SupportsBatching @InputRequirement(INPUT_REQUIRED) @Tags({"command execution","command","stream","execute"}) @CapabilityDescription("The ExecuteStreamCommand processor provides a flexible way to integrate external commands and scripts into NiFi data flows. ExecuteStreamCommand can pass the incoming FlowFile\'s content to the command that it executes similarly how piping works.") @SupportsSensitiveDynamicProperties @DynamicProperty(name="An environment variable name",value="An environment variable value",description="These environment variables are passed to the process spawned by this Processor") @DynamicProperty(name="command.argument.<commandIndex>",value="Argument to be supplied to the command",description="These arguments are supplied to the process spawned by this Processor when using the Command Arguments Strategy : Dynamic Property Arguments. <commandIndex> is a number and it will determine the order.") @WritesAttribute(attribute="execution.command",description="The name of the command executed") @WritesAttribute(attribute="execution.command.args",description="The semi-colon delimited list of arguments. Sensitive properties will be masked") @WritesAttribute(attribute="execution.status",description="The exit status code returned from executing the command") @WritesAttribute(attribute="execution.error",description="Any error messages returned from executing the command") @WritesAttribute(attribute="mime.type",description="Sets the MIME type of the output if the \'Output MIME Type\' property is set and \'Output Destination Attribute\' is not set") @Restricted(restrictions=@Restriction(requiredPermission=EXECUTE_CODE,explanation="Provides operator the ability to execute arbitrary code assuming all permissions that NiFi has.")) public class ExecuteStreamCommand extends org.apache.nifi.processor.AbstractProcessor

This processor executes an external command on the contents of a flow file, and creates a new flow file with the results of the command.

Properties:

  • Command Path
    • Specifies the command to be executed; if just the name of an executable is provided, it must be in the user's environment PATH.
    • Default value: none
    • Supports expression language: true
  • Arguments Strategy
    • Selects the strategy to use for arguments to the executable
      • Command Arguments Property: Use the delimited list of arguments from the Command Arguments Property. Does not support quotations in parameters.
      • Dynamic Property Arguments: Use Dynamic Properties, with each property a separate argument. Does support quotes.
  • Command Arguments
    • The arguments to supply to the executable delimited by the ';' character. Each argument may be an Expression Language statement.
    • Default value: none
    • Supports expression language: true
  • Working Directory
    • The directory to use as the current working directory when executing the command
    • Default value: none (which means whatever NiFi's current working directory is...probably the root of the NiFi installation directory.)
    • Supports expression language: true
  • Ignore STDIN
    • Indicates whether or not the flowfile's contents should be streamed as part of STDIN
    • Default value: false (this means that the contents of a flowfile will be sent as STDIN to your command
    • Supports expression language: false

Relationships:

  • original
    • The destination path for the original incoming flow file
  • output-stream
    • The destination path for the flow file created from the command's output, if the exit code is zero
  • nonzero-status
    • The destination path for the flow file created from the command's output, if the exit code is non-zero

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    (package private) static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    private static final org.apache.nifi.components.Validator
     
    private static final Set<org.apache.nifi.processor.Relationship>
     
    private static final Pattern
     
    (package private) static final org.apache.nifi.components.AllowableValue
     
    (package private) static final org.apache.nifi.components.AllowableValue
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    private org.apache.nifi.logging.ComponentLog
     
    private static final String
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.processor.Relationship
     
    static final org.apache.nifi.processor.Relationship
     
    static final org.apache.nifi.processor.Relationship
     
    private static final Set<org.apache.nifi.processor.Relationship>
     
    private static final List<org.apache.nifi.components.PropertyDescriptor>
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
    private final AtomicReference<Set<org.apache.nifi.processor.Relationship>>
     
    (package private) static final org.apache.nifi.components.PropertyDescriptor
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Set<org.apache.nifi.processor.Relationship>
     
    protected org.apache.nifi.components.PropertyDescriptor
     
    List<org.apache.nifi.components.PropertyDescriptor>
     
    protected void
    init(org.apache.nifi.processor.ProcessorInitializationContext context)
     
    void
    onPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue)
     
    void
    onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
     
    private static void
    readStdoutReadable(boolean ignoreStdin, OutputStream stdinWritable, org.apache.nifi.logging.ComponentLog logger, InputStream incomingFlowFileIS)
     

    Methods inherited from class org.apache.nifi.processor.AbstractProcessor

    onTrigger

    Methods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor

    getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue

    Methods inherited from class org.apache.nifi.components.AbstractConfigurableComponent

    customValidate, equals, getPropertyDescriptor, getPropertyDescriptors, hashCode, validate

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.nifi.components.ConfigurableComponent

    getPropertyDescriptor, getPropertyDescriptors, validate

    Methods inherited from interface org.apache.nifi.processor.Processor

    isStateful, migrateProperties, migrateRelationships
  • Field Details

    • ORIGINAL_RELATIONSHIP

      public static final org.apache.nifi.processor.Relationship ORIGINAL_RELATIONSHIP
    • OUTPUT_STREAM_RELATIONSHIP

      public static final org.apache.nifi.processor.Relationship OUTPUT_STREAM_RELATIONSHIP
    • NONZERO_STATUS_RELATIONSHIP

      public static final org.apache.nifi.processor.Relationship NONZERO_STATUS_RELATIONSHIP
    • relationships

      private final AtomicReference<Set<org.apache.nifi.processor.Relationship>> relationships
    • OUTPUT_STREAM_RELATIONSHIP_SET

      private static final Set<org.apache.nifi.processor.Relationship> OUTPUT_STREAM_RELATIONSHIP_SET
    • ATTRIBUTE_RELATIONSHIP_SET

      private static final Set<org.apache.nifi.processor.Relationship> ATTRIBUTE_RELATIONSHIP_SET
    • COMMAND_ARGUMENT_PATTERN

      private static final Pattern COMMAND_ARGUMENT_PATTERN
    • COMMAND_ARGUMENTS_PROPERTY_STRATEGY

      static final org.apache.nifi.components.AllowableValue COMMAND_ARGUMENTS_PROPERTY_STRATEGY
    • DYNAMIC_PROPERTY_ARGUMENTS_STRATEGY

      static final org.apache.nifi.components.AllowableValue DYNAMIC_PROPERTY_ARGUMENTS_STRATEGY
    • WORKING_DIR

      static final org.apache.nifi.components.PropertyDescriptor WORKING_DIR
    • ATTRIBUTE_EXPRESSION_LANGUAGE_VALIDATOR

      private static final org.apache.nifi.components.Validator ATTRIBUTE_EXPRESSION_LANGUAGE_VALIDATOR
    • EXECUTION_COMMAND

      static final org.apache.nifi.components.PropertyDescriptor EXECUTION_COMMAND
    • ARGUMENTS_STRATEGY

      static final org.apache.nifi.components.PropertyDescriptor ARGUMENTS_STRATEGY
    • EXECUTION_ARGUMENTS

      static final org.apache.nifi.components.PropertyDescriptor EXECUTION_ARGUMENTS
    • ARG_DELIMITER

      static final org.apache.nifi.components.PropertyDescriptor ARG_DELIMITER
    • IGNORE_STDIN

      static final org.apache.nifi.components.PropertyDescriptor IGNORE_STDIN
    • PUT_OUTPUT_IN_ATTRIBUTE

      static final org.apache.nifi.components.PropertyDescriptor PUT_OUTPUT_IN_ATTRIBUTE
    • PUT_ATTRIBUTE_MAX_LENGTH

      static final org.apache.nifi.components.PropertyDescriptor PUT_ATTRIBUTE_MAX_LENGTH
    • MIME_TYPE

      static final org.apache.nifi.components.PropertyDescriptor MIME_TYPE
    • PROPERTY_DESCRIPTORS

      private static final List<org.apache.nifi.components.PropertyDescriptor> PROPERTY_DESCRIPTORS
    • MASKED_ARGUMENT

      private static final String MASKED_ARGUMENT
      See Also:
    • logger

      private org.apache.nifi.logging.ComponentLog logger
  • Constructor Details

    • ExecuteStreamCommand

      public ExecuteStreamCommand()
  • Method Details

    • getRelationships

      public Set<org.apache.nifi.processor.Relationship> getRelationships()
      Specified by:
      getRelationships in interface org.apache.nifi.processor.Processor
      Overrides:
      getRelationships in class org.apache.nifi.processor.AbstractSessionFactoryProcessor
    • init

      protected void init(org.apache.nifi.processor.ProcessorInitializationContext context)
      Overrides:
      init in class org.apache.nifi.processor.AbstractSessionFactoryProcessor
    • onPropertyModified

      public void onPropertyModified(org.apache.nifi.components.PropertyDescriptor descriptor, String oldValue, String newValue)
      Specified by:
      onPropertyModified in interface org.apache.nifi.components.ConfigurableComponent
      Overrides:
      onPropertyModified in class org.apache.nifi.components.AbstractConfigurableComponent
    • getSupportedPropertyDescriptors

      public List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class org.apache.nifi.components.AbstractConfigurableComponent
    • getSupportedDynamicPropertyDescriptor

      protected org.apache.nifi.components.PropertyDescriptor getSupportedDynamicPropertyDescriptor(String propertyDescriptorName)
      Overrides:
      getSupportedDynamicPropertyDescriptor in class org.apache.nifi.components.AbstractConfigurableComponent
    • onTrigger

      public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) throws org.apache.nifi.processor.exception.ProcessException
      Specified by:
      onTrigger in class org.apache.nifi.processor.AbstractProcessor
      Throws:
      org.apache.nifi.processor.exception.ProcessException
    • readStdoutReadable

      private static void readStdoutReadable(boolean ignoreStdin, OutputStream stdinWritable, org.apache.nifi.logging.ComponentLog logger, InputStream incomingFlowFileIS)