98.7. 사용 예


98.7.1. 단어 수(Linux) 실행

아래 예제에서는 wc (단어 개수, Linux)를 실행하여 /usr/share/dict/words 파일의 단어를 계산합니다. 개수(출력)라는 단어가 wc 의 표준 출력 스트림에 기록됩니다.

from("direct:exec")
.to("exec:wc?args=--words /usr/share/dict/words")
.process(new Processor() {
     public void process(Exchange exchange) throws Exception {
       // By default, the body is ExecResult instance
       assertIsInstanceOf(ExecResult.class, exchange.getIn().getBody());
       // Use the Camel Exec String type converter to convert the ExecResult to String
       // In this case, the stdout is considered as output
       String wordCountOutput = exchange.getIn().getBody(String.class);
       // do something with the word count
     }
});
Copy to clipboard

98.7.2. java실행

아래 예제에서는 java 가 시스템 경로에 있는 경우 -server-version 과 함께 java 를 실행합니다.

from("direct:exec")
.to("exec:java?args=-server -version")
Copy to clipboard

아래 예제에서는 3개의 인수를 사용하여 java in c:\temp 를 실행합니다. -server,-version 및 sytem 속성 user.name.name.

from("direct:exec")
.to("exec:c:/program files/jdk/bin/java?args=-server -version -Duser.name=Camel&workingDir=c:/temp")
Copy to clipboard

98.7.3. ECDHE 스크립트 실행

다음 예제에서는 ant.gradle이 시스템 경로에 있고 CamelExecBuildFile.xml 이 현재 디렉터리에 있는 경우 빌드 파일 CamelExecBuildFile. xml 을 사용하여 Apache ECDHE(Windows만 해당)을 실행합니다.

from("direct:exec")
.to("exec:ant.bat?args=-f CamelExecBuildFile.xml")
Copy to clipboard

다음 예제에서 ant. knative 명령은 출력을 -l 을 사용하여 CamelExecOutFile.txt 로 리디렉션합니다. CamelExecOutFile.txt 파일은 outFile=CamelExecOutFile.txt 가 있는 출력 파일로 사용됩니다. 이 예에서는 ant.gradle 이 시스템 경로에 있고 CamelExecBuildFile.xml 이 현재 디렉터리에 있다고 가정합니다.

from("direct:exec")
.to("exec:ant.bat?args=-f CamelExecBuildFile.xml -l CamelExecOutFile.txt&outFile=CamelExecOutFile.txt")
.process(new Processor() {
     public void process(Exchange exchange) throws Exception {
        InputStream outFile = exchange.getIn().getBody(InputStream.class);
        assertIsInstanceOf(InputStream.class, outFile);
        // do something with the out file here
     }
  });
Copy to clipboard

98.7.4. 에코 실행 (Windows)

echodir 과 같은 명령은 운영 체제의 명령 인터프리터만 실행할 수 있습니다. 이 예에서는 Windows에서 echo - 같은 명령을 실행하는 방법을 보여줍니다.

from("direct:exec").to("exec:cmd?args=/C echo echoString")
Copy to clipboard
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat, Inc.