How to use pipes with $os.cmd()? #4946
Answered
by
ganigeorgiev
AfdhalAtiffTan
asked this question in
Q&A
-
Hello, For example, this command: ls | grep old I am not sure how to get the output into a variable: const cmd_a = $os.cmd('ls');
const cmd_b = $os.cmd('grep', 'old');
cmd_b.stdin = cmd_a.stdoutPipe();
// cmd_b.stdout = os.stdout; // ?
cmd_b.start();
cmd_a.run();
cmd_b.wait(); Any suggestions? |
Beta Was this translation helpful? Give feedback.
Answered by
ganigeorgiev
May 17, 2024
Replies: 1 comment 1 reply
-
I'm not sure how this could be easily done with the JSVM since we currently don't have a helper that will convert a writer into a string/bytes slice. A simpler alternative could be to invoke the |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
AfdhalAtiffTan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure how this could be easily done with the JSVM since we currently don't have a helper that will convert a writer into a string/bytes slice.
A simpler alternative could be to invoke the
sh -c
command instead, ex.$os.cmd('sh', '-c', 'ls | grep old')