$checksum()

DESCRIPTION
    returns various file checksums, also file sizes

    depending on the type, the checksums and file sizes returned are:

    type    checksum                                             size

     -3     returns the output of the system cksum command       
     -2     returns the output of the system sum command
     -1     returns the output of the system 'sum -r' command
      0     returns the null checksum (0)                        bytes
      1     returns the BSD-style sum computed internally        512-byte blocks
      2     returns the SysV-style sum computed internally       512-byte blocks
      3     returns the POSIX cksum computed internally          bytes
      4     returns the MD4 checksum                             bytes
      5     returns the MD5 checksum                             bytes

    $checksum(-3,a) and $checksum( 3,a) should return the same results
    $checksum(-2,a) and $checksum( 2,a) should return the same results
    $checksum(-1,a) and $checksum( 1,a) should return the same results
SYNOPSIS
    $checksum(-3,s)
    $checksum(-2,s)
    $checksum(-1,s)
    $checksum( 0,s)
    $checksum( 1,s)
    $checksum( 2,s)
    $checksum( 3,s)
    $checksum( 4,s)
    $checksum( 5,s)
ARGUMENTS
    -3,...,5 - an integer from -3 to 5, representing a checksum type;
           s - a quoted string, or string expression, representing a file name
EXAMPLES
# pikt +C 'output $checksum(-3,"/bin/login")'
3885748321 29712 /bin/login

# pikt +C 'output $checksum(-2,"/bin/login")'
34622 59 /bin/login

# pikt +C 'output $checksum(-1,"/bin/login")'
51340 59 /bin/login

# pikt +C 'output $checksum(0,"/bin/login")'
0 29712 /bin/login

# pikt +C 'output $checksum(1,"/bin/login")'
51340 59 /bin/login

# pikt +C 'output $checksum(2,"/bin/login")'
34622 59 /bin/login

# pikt +C 'output $checksum(3,"/bin/login")'
3885748321 29712 /bin/login

# pikt +C 'output $checksum(4,"/bin/login")'
0f4f6b25cec7f136ac8182fe9c45802a 29712 /bin/login

# pikt +C 'output $checksum(5,"/bin/login")'
ef1f166adc5291ab491496bde9fc8f77 29712 /bin/login
        begin
                set $findchksum = $checksum(5, "=find")
                if    #defined(%findchksum)
                   && $findchksum ne %findchksum
                        output mail "=find has changed checksum to $findchksum, was %findchksum"
                        // quit ?
                endif
        rule
                if ! -e $name
                        output mail "$name not found!"
                else
                        set $actual = $checksum(5, $name)
                        if $inlin ne $actual
                                output mail "$name checksums differ!"
                                output mail "      auth: $inlin"
                                output mail "    actual: $actual"
                        fi
                endif
        rule    // check MD5 sum
                set $sum5 = $checksum(5, $file)
                if    #defined(%sum5)
                   && $sum5 ne %sum5
                        output mail "MD5 checksum change: $sum5"
			next
                fi

#ifdef paranoid
        rule    // doublecheck with MD4 sum
                set $sum4 = $checksum(4, $file)
                if    #defined(%sum4)
                   && $sum4 ne %sum4
                        output mail "MD4 checksum change: $sum4"
			next
                fi
#endifdef
SEE ALSO
    String Functions
    Numerical Functions
 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2008-03-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
Learn about the
rkey
program