0

Fairly new to Linux. I have a nixie clock that runs off of a Raspberry Pi. I would like to send a random sequence of six digits to it every so often to help prolong the life of the Nixie tubes.

There is a CLITool program I found on GitHub that lets me display any six digits using the command CLITool xxxxxx, where x is any digit 0-9. So I tried creating a bash file with the line shuf -zer -n6 {0..9}|CLITool.

The shuf command produces a random six digit string of numbers, but it does not seem to get piped to the CLITool. Like I mentioned, fairly new to Linux, so it could be something basic I am missing.

terdon
  • 242,166
Joey29
  • 9

2 Answers2

2

You want to use command substitution.

 CLITool $(expr 1+2)

will first run the expr program with an argument of 1+2. This will output 3. Then the shell will run CLITool 3.

I would use awk to get the number, e.g.

 CLItool $(awk 'BEGIN{srand();printf("%06d\n",rand()*1000000)}')

to get a 6 digit random number with leading 0s between 0 and 1,000,000-1.

icarus
  • 17,920
2

Sounds like your CLI tool simply doesn't read input from stdin. Only tools that can read input streams can be piped to. So just use command substitution instead:

CLItool $(shuf -zer -n6 {0..9})
terdon
  • 242,166