[ 
https://issues.apache.org/jira/browse/FLUME-1661?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13489406#comment-13489406
 ] 

Nitin Verma edited comment on FLUME-1661 at 11/2/12 1:30 PM:
-------------------------------------------------------------

This is my thinking, we should invoke a shell not the command and let the shell 
do the parsing.
We can call this as ShellExecSource, with user's choice of the shell.

Following is an example of /bin/sh that tried with a command: "ls -la ; pwd \n 
`which cat` /etc/passwd >&2"
and it works.

{code:java}
          //String[] commandArgs = command.split("\\s+"); // let user-command 
be as is.
          process = new ProcessBuilder("/bin/sh").start();

          final OutputStream outputStream = process.getOutputStream();
          outputStream.write(command.getBytes());
          outputStream.write('\n');
          outputStream.flush();

          outputStream.close();
{code}

This way we do not have to worry about all the shells

    Bourne shell (sh)
    Almquist shell (ash)
    Bourne-Again shell (bash)
    Debian Almquist shell (dash)
    Public domain Korn shell (pdksh)
    MirBSD Korn shell (mksh)
    Z shell (zsh)
    C shell (csh)
    TENEX C shell (tcsh)
     etc...


                
      was (Author: nitin_matrix):
    This is my thinking, we should invoke a shell not the command and let the 
shell do the parsing.
We can call this as ShellExecSource, with user's choice of the shell.

Following is an example of /bin/sh that tried with a command: "ls -la ; pwd \n 
`which cat` /etc/passwd >&2"
and it works.

          //String[] commandArgs = command.split("\\s+"); // let user-command 
be as is.
          process = new ProcessBuilder("/bin/sh").start();

          final OutputStream outputStream = process.getOutputStream();
          outputStream.write(command.getBytes());
          outputStream.write('\n');
          outputStream.flush();

          outputStream.close();

This way we do not have to worry about all the shells

    Bourne shell (sh)
    Almquist shell (ash)
    Bourne-Again shell (bash)
    Debian Almquist shell (dash)
    Public domain Korn shell (pdksh)
    MirBSD Korn shell (mksh)
    Z shell (zsh)
    C shell (csh)
    TENEX C shell (tcsh)
     etc...


                  
> ExecSource cannot execute (little complicated..) *nix commands
> --------------------------------------------------------------
>
>                 Key: FLUME-1661
>                 URL: https://issues.apache.org/jira/browse/FLUME-1661
>             Project: Flume
>          Issue Type: Improvement
>          Components: Sinks+Sources
>    Affects Versions: v1.2.0
>            Reporter: Yoonseok Woo
>            Assignee: Roshan Naik
>             Fix For: v1.3.0
>
>         Attachments: FLUME-1661-1.patch, FLUME-1661.patch, FLUME-1661.patch.v2
>
>
> * command line parsing
> ** conf/flume.conf
> {code}
> agent.sources.source1.type = exec
> agent.sources.source1.command = tail -f 
> /some/path/logs/exception/error.log.`date +%Y%m%d%H`
> {code}
> ** result
> {code}
> tail: /some/path/logs/exception/error.log.`date: No such file or directory
> tail: +%Y%m%d%H`: No such file or directory
> {code}
> ** needs to be improved
> {code}
> (ExecSouce.java:242) String[] commandArgs = command.split("\\s+") 
> {code}
> * using special character (e.g. *, `, ', ...)
> ** conf/flume.conf
> {code}
> agent.sources.source1.type = exec
> agent.sources.source1.command = tail -f /some/path/logs/exception/error.log.*
> {code}
> ** result
> {code}
> tail: /some/path/logs/exception/error.log.*: No such file or directory
> {code}
> ** needs to be improved
> {code}
> (ExecSouce.java:243) process = new ProcessBuilder(commandArgs).start();
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to