test-popen.nut 448 B

1234567891011121314151617
  1. //local fd = assert(popen("/bin/ls -la", "r"));
  2. local fd = popen("/bin/ls -la", "r");
  3. local output = "";
  4. local read_n = 1024;
  5. local read_buf;
  6. do
  7. {
  8. read_buf = fd.read(read_n);
  9. output += read_buf;
  10. } while(read_buf.len() == read_n);
  11. print("pclose", fd.close());
  12. print(output) // Prints the output of the command.
  13. fd = popen("/bin/ls -la", "r");
  14. output = fd.read_all();
  15. print("pclose", fd.close());
  16. print(output) // Prints the output of the command.