Deconstructing a perl-based one-Liner error occurs "Can’t Modify single ref constructor in scalar assignment"

Asked

Viewed 75 times

2

2 answers

0

it is not very clear what you are to do, but tries something like:

perl -'MDigest::MD5 md5' -ne 'BEGIN{$/=\1024};print md5($_)'

or to make it more legible:

perl -'MDigest::MD5 md5_hex' -ne 'BEGIN{$/=\1024};print "\n$.:, md5_hex($_),"\n"'

0

I may be wrong, but the bar in front of 1024 is to escape the argument passed to the /root/.ssh/rsync_rsa (in accordance with response in the Severfault):

ssh -i /root/.ssh/rsync_rsa $remote "
  perl -'MDigest::MD5 md5' -ne 'BEGIN{\$/=\1024};print md5(\$_)' $dev2 | lzop -c" |
  lzop -dc | perl -'MDigest::MD5 md5' -ne 'BEGIN{$/=\1024};$b=md5($_);
    read STDIN,$a,16;if ($a eq $b) {print "s"} else {print "c" . $_}' $dev1 | lzop -c |
ssh -i /root/.ssh/rsync_rsa $remote "lzop -dc |
  perl -ne 'BEGIN{\$/=\1} if (\$_ eq\"s\") {\$s++} else {if (\$s) {
    seek STDOUT,\$s*1024,1; \$s=0}; read ARGV,\$buf,1024; print \$buf}' 1<> $dev2"

So in your case as you don’t is flowing by rsync_rsa and yes typing straight, do not need to "escape" the number, just do that:

export dev2='/dev/sdb';
perl -'MDigest::MD5 md5' -ne 'BEGIN{\$/=1024};print md5(\$_)' $dev2

I am without terminal emulator, but if it still fails it is because it does not need to escape the $ inside '...' (I can’t say I haven’t used Linux/Unix in a while):

export dev2='/dev/sdb';
perl -'MDigest::MD5 md5' -ne 'BEGIN{$/=1024};print md5($_)' $dev2

Browser other questions tagged

You are not signed in. Login or sign up in order to post.