Reputation: 21
Below is the command which is executed when I install the application(this line written in one of the script of our application).
PASS=strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 10 | tr -d '\n'
every time I get the error "grep: write error: pipe broken".
here are few points to be noted
Also, I have tried few other ways to generate alphanumaric character like:
X=strings /dev/urandom | grep -o -m15 '[[:alnum:]]'
PASS=echo "$X" | head -n 10 | tr -d '\n'
PASS=strings /dev/urandom | tr -dc A-Za-z0-9 | head -c10
PASS=cat /dev/urandom | tr -dc A-Za-z0-9 | head -c10
X=strings /dev/urandom | head -n 100
PASS=echo "X" | grep -o '[[:alnum:]]' | head -n 10 | tr -d '\n'
PASS=< /dev/urandom tr -dc '[[:alnum:]]' | head -c10
None of this worked on RHEL 8.X while installing application. However all this command works fine when executing directly on terminal.
Upvotes: 1
Views: 2115
Reputation: 19375
The command
PASS=`strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 10 | tr -d '\n'`
does not work due to a bug in strings
. head
exits after having read 10 lines; grep
detects that the other end of its output pipe has been closed, issues grep: write error: Broken pipe
and also exits; strings
ignores that the other end of its output pipe has been closed and blindly continues endlessly.
The commands 3. and 5. which don't use strings
correctly generate a 10 character password, although 3. also issues write error: Broken pipe
.
Upvotes: 1