perlquestion
adroc
<p>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.
</p>
<code>
$hash1= `makepasswd --clearfrom=$path/keys/temppw --crypt-md5 --verbose | grep Password=| cut -d"=" -f3`;
chomp($hash1);
$hash2=`makepasswd --clearfrom=$path/keys/temppw2 --crypt-md5 --verbose | 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 machine 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");
</code>
<p>
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.
</p>
<p>
Some example hashes..........
</p>
<p>
$1$UGXeHYG/$c8iQxpnMsSSCWlEPo0utZTxDjc.qCyTD59PjclG3iKW8p.ZRCySuul8mfl2xffClNH6m/0MqpbIaaHCsI/ziY0
</p>
<p>
$1$mOdDtc/f$iKpqV8NR7mfM9DrJ7ebS1/
</p>
<p>
What am I doing wrong here?
</p>
<p>
Thanks in advance...
</p>