question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running command that pipes to another command

See original GitHub issue

Describe the problem

Currently, there is no way via the API to pipe the output of a command into another command. For example to run something similar to:

echo '{"key":"value"}' | jq '.'

Describe your solution

  • Work out how to actually pipe one command into another using Process as currently it doesn’t work. Likely the issue relates to the standard out and in being redirected/captured as streams.
  • Commands can be a structure rather than just executed immediately as a function like now.
  • A Pipeline structure can then be built from a series of Commands and then executed all together with each command piping into the next.

Checklist

Additional context

It looks like a change may be made with how the command(s) are prepared and built using ProcessBuilder so that they are executed correctly.

Workaround Currently, you can run multiple commands by simply capturing the output of the first command into a Kotlin property and then running the second command using its value as input.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
lordcodescommented, Aug 11, 2022

I agree. I have created #120 to track the Command abstraction.

0reactions
jmfayardcommented, Aug 11, 2022

If the dependency is an issue, we can put the pipeline feature in a separate module.

Also it was fun to discuss but I don’t really need pipelines right now.

Having the Command abstraction on the other hand would be really helpful.

Le jeu. 11 août 2022 à 13:26, Andrew Lord @.***> a écrit :

Maybe I just don’t see it until I would try and work on it, however, there is no threading now and the pipeline would be running the commands sequentially. I don’t see the difference to just running one command at a time in a process like they are now, but that each commands reads in from stream.

Anyway, realistically I’m not going to look into this or work on this anytime soon. If you would like this soon, then you are welcome to work on something. However, I’m really not a fan of introducing that library as a dependency, due to the fact it is a Java library with no recent changes. If threading and a lot of complexity is required to implement this, i.e. it isn’t as simple as it seems to me 🤣, pipelines could be built as a separate library potentially.

— Reply to this email directly, view it on GitHub https://github.com/lordcodes/turtle/issues/104#issuecomment-1211861240, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQFSH4P76O2A4TYJNXMY3VYTPNVANCNFSM5Z6BSIKQ . You are receiving this because you commented.Message ID: @.***>

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to pipe command output to other commands? - bash
Save this answer. Show activity on this post. This can be achieved in several ways, such as pipe | , STDERR 2> ,...
Read more >
Working with pipes on the Linux command line
One of the most powerful shell operators is the pipe ( | ). The pipe takes output from one command and uses it...
Read more >
Pass the output of previous command to next as an argument
I generally use `command` to place it's output as argument to another command. For e.g., to find resource consumed by process foo on...
Read more >
Learn the Command Line: Redirecting Input and Output ...
The | command is called a pipe. It is used to pipe, or transfer, the standard output from the command on its left...
Read more >
Pipe, Grep and Sort Command in Linux/Unix with Examples
The Pipe is a command in Linux that lets you use two or more commands such that output of one command serves as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found