The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 03-30-2006
berrean berrean is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 4
SSH and SCP

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



Code:
#!/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


Last edited by berrean; 03-30-2006 at 03:22 PM..
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:44 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0