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

17
LINES

< > BotCompany Repo | #1009098 // backtickToConsoleX - run external process, print its output to Java console and call function on output

JavaX fragment (include)

// returns file with program output (STDOUT+STDERR)
static File backtickToConsoleX(S cmd, fO outputReceiver) {
  File outputFile = createTempFile(cmd, ".out");
  makeEmptyFile(outputFile); // unnecessary?
  TailFile tail = tailFile2(outputFile, 1000, voidfunc(S s) {
    printNoNewLine(fixNewLines(s));
    pcallF(outputReceiver, s);
  });
  
  // make a dependent child process that is exited when we exit
  print("Running: " + cmd);
  pcall {
    backtickToFile(cmd, outputFile);
  }
  tail.stop();
  ret outputFile;
}

Author comment

Began life as a copy of #1009090

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1009098
Snippet name: backtickToConsoleX - run external process, print its output to Java console and call function on output
Eternal ID of this version: #1009098/3
Text MD5: 24f8e75b05758f4b1ffeed550bca4eac
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-30 16:53:03
Source code size: 536 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 520 / 561
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1009576 - backtickToConsole_lineBuf - run external process, print its output to Java console and call function on output lines
#1016739 - backtickToReceiver - run external process and call function on output