* Automatic CTRL-D (EOF)
@ 2008-03-11 13:07 Mário Gamito
2008-03-11 13:27 ` Jose Celestino
0 siblings, 1 reply; 2+ messages in thread
From: Mário Gamito @ 2008-03-11 13:07 UTC (permalink / raw)
To: Linux-Admin ML
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
command prompt.
I've searched all over Google, but either I didn't use the right search
strings or there is nothing relevant about this.
Bottom line is that I need this command to print the password hash and
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ário 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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Automatic CTRL-D (EOF)
2008-03-11 13:07 Automatic CTRL-D (EOF) Mário Gamito
@ 2008-03-11 13:27 ` Jose Celestino
0 siblings, 0 replies; 2+ messages in thread
From: Jose Celestino @ 2008-03-11 13:27 UTC (permalink / raw)
To: Mário Gamito; +Cc: Linux-Admin ML
Words by Mário 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 the
> command prompt.
>
No, it just expects EOF.
> I've searched all over Google, but either I didn't use the right search
> strings or there is nothing relevant about this.
>
> Bottom line is that I need this command to print the password hash and
> 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"
--
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-11 13:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-11 13:07 Automatic CTRL-D (EOF) Mário Gamito
2008-03-11 13:27 ` Jose Celestino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).