Automatic CTRL-D (EOF)

Automatic CTRL-D (EOF)

am 11.03.2008 14:07:54 von gamito

Hi,

I have a script that has to perform a hash over a password.
Problem is that sha512sum expects CTRL-D to be pressed to return to the=
=20
command prompt.

I've searched all over Google, but either I didn't use the right search=
=20
strings or there is nothing relevant about this.

Bottom line is that I need this command to print the password hash and=20
returns to the shell automatically:

$ sha512sum | xargs echo "password" | cut -f2 -d' '

Tried:

$ read x; echo "$x" | sha512sum | xargs echo "password" | cut -f2 -d' =
'

but no good and as a bonus (NOT) the hash is incorrect.

Any help would be appreciated.

Warm Regards,
M=E1rio Gamito
--
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: Automatic CTRL-D (EOF)

am 11.03.2008 14:27:22 von Jose Celestino

Words by M=E1rio Gamito [Tue, Mar 11, 2008 at 01:07:54PM +0000]:
> Hi,
>
> I have a script that has to perform a hash over a password.
> Problem is that sha512sum expects CTRL-D to be pressed to return to t=
he=20
> command prompt.
>

No, it just expects EOF.

> I've searched all over Google, but either I didn't use the right sear=
ch=20
> strings or there is nothing relevant about this.
>
> Bottom line is that I need this command to print the password hash an=
d=20
> returns to the shell automatically:
>
> $ sha512sum | xargs echo "password" | cut -f2 -d' '
>
> Tried:
>
> $ read x; echo "$x" | sha512sum | xargs echo "password" | cut -f2 -d=
' '
>
> but no good and as a bonus (NOT) the hash is incorrect.

That is because echo adds a \n at the end of the string.

You should also do a silent read (-s):

read -s ; echo -n "$REPLY" | sha512sum | xargs echo "password"

--=20
Jose Celestino
------------------------------------------------------------ ----
http://www.msversus.org/ ; http://techp.org/petition/show/1
http://www.vinc17.org/noswpat.en.html
------------------------------------------------------------ ----
"If you would have your slaves remain docile, teach them hymns."
-- Ed Weathers ("The Empty Box")
--
To unsubscribe from this list: send the line "unsubscribe linux-admin" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html