CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Find and replace MD5 hash from file


New User

Jun 29, 2011, 11:24 AM

Post #1 of 1 (970 views)
Find and replace MD5 hash from file Can't Post

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 --verbose | grep Password=| cut -d"=" -f3`;

$hash2=`makepasswd --clearfrom=$path/keys/temppw2 --crypt-md5 --verbose | grep Password=| cut -d"=" -f3`;

#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/$hash1/$hash2/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..........



What am I doing wrong here?

Thanks in advance...

(This post was edited by adroc on Jun 29, 2011, 11:57 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives