Re: [Hampshire] Bash pipe creates infinite loop - why?

Top Page

Reply to this message
Author: Bob Dunlop
Date:  
To: hampshire
Subject: Re: [Hampshire] Bash pipe creates infinite loop - why?
Hi,

On Wed, Apr 02 at 04:28, Russell Gadd wrote:
> I'm sure one of you gurus will be able to see my error in a trice and
> enlighten me. As a relative newcomer I am having difficulty with an infinite

...
> #**************** this is the offending line ***********************
>    echo -e "${PASS1}\n${PASS1}" |bcrypt -r testfile 2> bcryptoutput.txt


Actually the pipe is not causing the loop it's the poor design of bcrypts
key input. bcrypt doesn't check for end of input when reading the key in
and hence once it's read and rejected the first pair it will loop forever
processing nothing. There's no easy fix for this other then getting
someone to fix bcrypt, or use a different encryption program.



Your method for checking for an error is somewhat baroque as well. In
common with most programs bcrypt returns an exit status that indicates
and error so you could simply do:

if echo -e "${PASS1}\n${PASS1}" |bcrypt -r testfile 2> bcryptoutput.txt
then
    echo all ok
else
    echo error:
    cat  bcryptoutput.txt
fi


-- 
        Bob Dunlop