Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1035472 // apacheCommonsExec

JavaX fragment (include) [tags: use-pretranspiled]

Uses 107K of libraries. Click here for Pure Java version (8456L/48K).

lib 1013692

sS apacheCommonsExec(LS args) ctex {
  var cmdLine = new org.apache.commons.exec.CommandLine(first(args));
  for (arg : dropFirst(args))
    cmdLine.addArgument(arg);
  ret apacheCommonsExec(cmdLine);
}

sS apacheCommonsExec(S cmd) {
  ret apacheCommonsExec(org.apache.commons.exec.CommandLine.parse(cmd));
}

sS apacheCommonsExec(org.apache.commons.exec.CommandLine cmdLine) ctex {
  delegate DefaultExecutor, PumpStreamHandler to org.apache.commons.exec.
  
  new DefaultExecutor executor;
  new ByteArrayOutputStream baos;
  OutputStream stream = teeOutputStream(printOutputStream(), baos);
  PumpStreamHandler pump = new(stream, stream);
  executor.setStreamHandler(pump);
  print("Exit value: " + executor.execute(cmdLine));
  ret fromUTF8(toByteArray(baos));
}

Author comment

Began life as a copy of #1006739

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035472
Snippet name: apacheCommonsExec
Eternal ID of this version: #1035472/7
Text MD5: 8670eaa17b69b967f3013d1461ce5097
Transpilation MD5: 79a0f2437084dc504130422a1cfcd5c5
Author: stefan
Category: javax / os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-05-22 19:15:14
Source code size: 802 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 119 / 191
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)