The following ksh script is trying to get a file's cksum then, scp it over to a remote machine - get the cksum there and then compare the two cksums to make sure they match. I am having problems setting a variable on the remote host where it can be read locally. Is this even possible - reading a shell variable from a remote host? I have the ssh and scp file transfer working properly. The two problems I am having are logging to the remote host's syslog.log and exporting $REMOTECKSUM for comparison. Any help or guidance is appreciated.
Thanks,
berrean
#!/usr/bin/ksh
MACHINE=$1
FILENAME=$2
DESTFILENAME=$3
#DEBUG echo "connecting to: $MACHINE"
# Get the local cksum and write it to a local log
cksum $FILENAME >> local.log
LOCALCKSUM=$(cksum $FILENAME)
# write an entry to the local syslog
logger -t TESTLOCALCKSUM -f local.log
# do scp here
#DEBUG echo "connecting to: $MACHINE"
#DEBUG echo "filename is: $FILENAME"
#DEBUG echo "destfilename is: $DESTFILENAME"
#DEBUG echo "command is /usr/local/bin/scp2 $FILENAME $MACHINE:$DESTFILENAME"
/usr/local/bin/scp2 $FILENAME $MACHINE:$DESTFILENAME
# Write the remote cksum to a remote log and VARIABLE then log this in remote syslog
/usr/local/bin/ssh2 $MACHINE "cksum $DESTFILENAME >> remote.log; export REMOTECKSUM='$(cksum $DESTFILENAME)'; logger -t TESTREMOTECKSUM -f remote.log"
if [[ "$LOCALCKSUM" = "$REMOTECKSUM" ]]; then
print -- "CHECKSUMS MATCH --- SUCCESS!!"
print -- "local cksum: $LOCALCKSUM"
print -- "remote cksum $REMOTECKSUM"
else
print -- "CHCEKSUMS DO NOT MATCH --- FAILURE!!"
print -- "local cksum: $LOCALCKSUM"
print -- "remote cksum $REMOTECKSUM"
fi