Hello, I am attempting to do a search and replace of MD5 hashes contained in a file but am having issues with the special characters contained within the hash. For example: #Just generating random hashes for this example and storing them in variables.

$hash1= `makepasswd --clearfrom=$path/keys/temppw --crypt-md5 --verbos +e | grep Password=| cut -d"=" -f3`; chomp($hash1); $hash2=`makepasswd --clearfrom=$path/keys/temppw2 --crypt-md5 --verbos +e | grep Password=| cut -d"=" -f3`; chomp($hash2); #I need to update the hashes over ssh because I will be doing this on +remote machines, so I'm doing the following to test on the local mach +ine for now.... system("ssh -o StrictHostKeyChecking=no root\@localhost /usr/bin/perl +-p -i -e s/$hash2/$hash1/ee hashfile") == 0 or @errors=(@errors,"\n$server hash update error: $?\n");

Doing the above generates an error similar to this. Bareword found where operator expected at -e line 1, near "s/$/7OWwo4h/FWHShP3" syntax error at -e line 1, near "s/$/7OWwo4h/FWHShP3" Execution of -e aborted due to compilation errors.

Some example hashes..........

$1$UGXeHYG/$c8iQxpnMsSSCWlEPo0utZTxDjc.qCyTD59PjclG3iKW8p.ZRCySuul8mfl2xffClNH6m/0MqpbIaaHCsI/ziY0

$1$mOdDtc/f$iKpqV8NR7mfM9DrJ7ebS1/

What am I doing wrong here?

Thanks in advance...


In reply to Find and replace MD5 hash from file by adroc

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.