http://www.perlmonks.org?node_id=912016


in reply to Find and replace MD5 hash from file

I can see two problems with your system command: (1) parts of your hashed password strings contain $ signs which will be interpreted by the shell as environment variables. (2) If you then single quote your s/// expression to protect from shell interpolation, those same $ signs are interpreted as variables by Perl; the slashes are also interpreted by Perl. So replace this:

system("ssh -o StrictHostKeyChecking=no root\@localhost /usr/bin/perl +-p -i -e s/$hash2/$hash1/ee ha +shfile")

with this:

system("ssh -o StrictHostKeyChecking=no root\@localhost /usr/bin/perl +-p -i -e 's/\Q$hash2\E/\Q$hash1\E/' ha +shfile")