adroc has asked for the wisdom of the Perl Monks concerning the following question:
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...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Find and replace MD5 hash from file
by philipbailey (Curate) on Jun 29, 2011 at 19:07 UTC | |
by ikegami (Patriarch) on Jun 29, 2011 at 19:32 UTC | |
by philipbailey (Curate) on Jun 29, 2011 at 19:45 UTC | |
by ikegami (Patriarch) on Jun 29, 2011 at 20:19 UTC | |
by philipbailey (Curate) on Jun 29, 2011 at 20:36 UTC | |
| |
Re: Find and replace MD5 hash from file
by ikegami (Patriarch) on Jun 29, 2011 at 19:15 UTC | |
by adroc (Initiate) on Jun 29, 2011 at 20:18 UTC | |
by ikegami (Patriarch) on Jun 29, 2011 at 20:28 UTC | |
by adroc (Initiate) on Jun 29, 2011 at 22:35 UTC |