Piping output from one command into another command #3447
-
It's there a way of piping the output of a command into another? I'm trying to make this example working. But the let child = tokio::process::Command::new("ls")
.stdout(std::process::Stdio::piped())
.spawn()?;
tokio::process::Command::new("grep")
.arg("a")
.stdin(child.stdout.unwrap())
.spawn()?; I get the following error:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @serbanrobu, thanks for bringing this up! As things stand today there isn't an ergonomic way to perform the conversion, but I've opened #3466 which should make this easier to perform the conversion. In the meantime, you could try getting yourself unblocked by manually creating an anonymous pipe and passing in the write/read ends into the child processes (tokio will not capture and manage the child's stdio handles if they are explicitly set to a particular file descriptor). Hope this helps, but don't hesitate to ask if you have other questions! |
Beta Was this translation helpful? Give feedback.
Hi @serbanrobu, thanks for bringing this up! As things stand today there isn't an ergonomic way to perform the conversion, but I've opened #3466 which should make this easier to perform the conversion.
In the meantime, you could try getting yourself unblocked by manually creating an anonymous pipe and passing in the write/read ends into the child processes (tokio will not capture and manage the child's stdio handles if they are explicitly set to a particular file descriptor).
Hope this helps, but don't hesitate to ask if you have other questions!