Reputation: 87
I am new to Busybox and I found that process substitution don't work in Busybox. Can anyone help me to emulate below command in Busybox using named pipe.
cat <(echo 0 0 1 /config/camConfig.txt 0 3840 2160 8 0 0) - | ~/tools/camera/stream
I am developing a camera which runs on Busybox. In order to stream camera for analysis I need to start an application /tools/camera/stream, but every time I run this application I need to insert same set of information to the application manually, then it will start stream, after analysis is complete I need to enter number 13 in application to stop camera. So I want to automate this task and I tried above command. Later I found that I cannot do this. I tried the below command but only the first input 0 is passed to application.
[ -p ~/config/settings.txt ] || mkfifo ~/config/settings.txt
echo 0 0 1 /config/camConfig.txt 0 3840 2160 8 0 0 > ~/config/settings.txt &
cat <~/config/settings.txt - | ~/tools/camera/stream
Please help me to find a solution.
Upvotes: 1
Views: 453
Reputation: 361729
<(...)
is a Bash-ism and Busybox only supports plain sh syntax. An sh-compatible way to do this is to run echo
and cat
in within curly braces and pipe the resulting compound command to your tool.
{ echo 0 0 1 /config/camConfig.txt 0 3840 2160 8 0 0; cat; } | ~/tools/camera/stream
I would do this even in Bash as it's a more direct and thus more efficient expression of what you're trying to do.
For what it's worth, I think your solution would work if you removed the <
redirection from the final line.
cat ~/config/settings.txt - | ~/tools/camera/stream
Why not use <
? You're trying to cat
both a pipe and stdin. If you use <
that causes settings.txt
to be redirected to stdin, which conflicts with the -
and means stdin is no longer connected to the keyboard.
Also, I'd probably stick the pipe in /run
, which is for ephemeral runtime files—perfect for pipes. (Or, alternatively, /var/run
or /tmp
.) And I'd give it a .fifo
extension to indicate it's not a regular file.
Upvotes: 2