0
$\begingroup$

Rosanswers logo

I'd like to use launch-prefix to pipe the stdout of a program (netcat) to the stdin of a ros node.

It works fine when launched from rosrun:

netcat 10.0.0.10 8001 | rosrun foo stdin_to_msg.py

I can also copy the command line that roslaunch generates (determined by ps -aux | grep stdin_to_msg.py) and run that successfully, but when run in the launch file the stdout from netcat is sent to the stdout of the roslaunch terminal if output="screen" (or nowhere if not, or a log file?), and the node itself never starts.

<node name="stdin_to_msg" pkg="foo" type="stdin_to_msg.py"
    launch-prefix="netcat 10.0.0.10 8001 |" output="screen"/>

Probably I can wrap this in a bash script and run that from roslaunch, but I'm curious if there is an in-launch solution.


Originally posted by lucasw on ROS Answers with karma: 8729 on 2017-09-19

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

For what you're trying to do it would require roslaunch to do string concatenation and then execute it in bash. For using subprocesses that's generally not recommended due to potential security vulnerabilities. It instead is directly calling the executables and appending arguments directly.

If you do want to do the piping and other bashisms writing your stuff into a bash script is what I would recommend.


Originally posted by tfoote with karma: 58457 on 2017-09-19

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.