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

15
LINES

< > BotCompany Repo | #1009090 // backtickToConsole - run external process and print its output to Java console; blocks until done

JavaX fragment (include)

// returns file with program output (STDOUT+STDERR)
static File backtickToConsole(S cmd) {
  ping();
  File outputFile = createTempFile(cmd, ".out");
  makeEmptyFile(outputFile); // unnecessary?
  TailFile tail = tailFile2(outputFile, 1000, l1 printNoNewLine_fix);
  
  // 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 #1006739

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1009090
Snippet name: backtickToConsole - run external process and print its output to Java console; blocks until done
Eternal ID of this version: #1009090/11
Text MD5: 926f2f7eb474c0878c0803f8e4c71ee4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-03 21:32:17
Source code size: 459 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 593 / 650
Version history: 10 change(s)
Referenced in: [show references]