On 11/10/2016 10:12 AM, Pierre Labastie wrote:


I see. I still think you could try "perl -e <perl command>" for this
part of the script.

I don't know how to do it that way. I ultimately did it using awk ranges (much cleaner than the double loop, and certainly better than calling an external script) with printf to concatenate them, then external printf to do the octal conversion. I think this would be correct for perl -e, not sure if I can kill all the white space (of if even this is right, but it should be close):

awk '/^CKA_VALUE/{flag=1;next}/^END/{flag=0}flag' ${tempfile} | \
    $(perl -e 'my @bs = split( /\\/ );
                foreach my $b (@bs)
                    { chomp $b;
                       printf( "%c", oct($b) ) unless $b eq \'\';
                     }
               }' | \
    /usr/bin/openssl x509 -text -inform DER -fingerprint \
    > tempfile.crt

But this is what I went with:

printf $(awk '/^CKA_VALUE/{flag=1;next}/^END/{flag=0}flag{printf $0}' \
"${tempfile}") | /usr/bin/openssl x509 -text -inform DER -fingerprint \
> tempfile.crt

--DJ

--
http://lists.linuxfromscratch.org/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to