- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Help ksh script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2009 07:20 PM
тАО05-12-2009 07:20 PM
Terms:
OFA = Original File on Server A
TFA = Target File on Server A
TFB = Target FIle on Server B
I want to create script that do the following steps:
1)copy file on server A from OFA to TFA
2)check using md5sum OFA and TFA
if (md5sum OFA = md5sum TFA) then
gzip TFA
md5sum TFA.gz
else go to step 1)
3)rcp -p serverA:TFA.gz serverB:TFB.gz
md5sum TFB.gz
if (md5sum TFA.gz = md5sum TFB.gz) then
remsh B gunzip TFB.gz
remsh B chmod 444 TFB
else go to 3)
Please help.
Many thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-12-2009 10:21 PM
тАО05-12-2009 10:21 PM
Solution#1)copy file on server A from OFA to TFA
while : ; do
cp -f $OFA $TFA
#2)check using md5sum OFA and TFA
#This is a waste of time
diff $OFA $TFA > /dev/null
if [ $? -eq 0 ]; then
rm -f $TFA.gz
gzip $TFA
MD5=$(md5sum $TFA.gz | awk '{print $1}')
break
fi
done
#3)rcp -p serverA:TFA.gz serverB:TFB.gz
while : ; do
remsh $serverB -n rm -f $TFB.gz
rcp -p $TFA.gz $serverB:$TFB.gz
MD5B=$(remsh $serverB -n md5sum $TFB.gz | awk '{print $1}')
# if (md5sum TFA.gz = md5sum TFB.gz) then
if [ "$MD5" = "$MD5B" ]; then
remsh $serverB -n rm -f $TFB
remsh $serverB -n gunzip $TFB.gz
remsh $serverB -n chmod 444 $TFB
break
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 12:10 AM
тАО05-13-2009 12:10 AM
Re: Help ksh script
Many thanks for your help.
Dear All,
Any another suggested script?
Many thanks in advanced.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 01:00 AM
тАО05-13-2009 01:00 AM
Re: Help ksh script
#2)check using md5sum OFA and TFA
#This is a waste of time
if [ -f "$TFA" ] ; then
diff $OFA $TFA > /dev/null
if [ $? -eq 0 ]; then
rm -f $TFA.gz
gzip $TFA
MD5=$(md5sum $TFA.gz | awk '{print $1}')
break
fi
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 01:14 AM
тАО05-13-2009 01:14 AM
Re: Help ksh script
Dear All please more suggested scripts.
Many thanks in advanced.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 05:22 AM
тАО05-13-2009 05:22 AM
Re: Help ksh script
The reason he wants to do the md5sum is to verify the remote copy was completed successfully. Copying the file locally, then rcp'ing it doesn't satisfy that concern.
I *much* prefer ssh/scp to remsh and rcp. All the convenience plus security. You effectively have your script from your description. The requirements were quite specific and easily translated into ksh:
lm=1
om=2
while [ "${lm}" != "${om}" ]
do
scp -q $OFA ${target_host}:${TFA}
lm=$(md5sum $OFA}
om=$(ssh ${target_host} md5sum ${TFA})
done
## Note: if you *actually* want to copy from the second server to a third server, you will need to use ssh/scp. remsh/rcp doesn't support that concept.
## The only reason I can see to do that is if the local host and the 2nd remote host don't have direct connectivity. Otherwise, it's simpler just to reiterate the loop above using the 2nd host as target_host.
scp -q ${target_host}:$TFA ${remote_host}:$TFB
lm=1; om=2
while [ "${lm}" != "${om}" ]
do
lm=$(ssh ${target_host} md5sum ${TFA})
om=$(ssh ${remote_host} md5sum ${TFB})
done
HTH;
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 06:18 PM
тАО05-13-2009 06:18 PM
Re: Help ksh script
(( limit = 5 ))
while (( (limit -= 1) >= 0 )); do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-13-2009 10:48 PM
тАО05-13-2009 10:48 PM
Re: Help ksh script
More improvements in script are welcome.
Many thanks in advanced.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-14-2009 03:16 AM
тАО05-14-2009 03:16 AM
Re: Help ksh script
BTW, Dennis:
To check two local files for equalness, I prefer
if cmp -s file1 file2
then print equal files
else print file differ
fi
The 'cmp' stops at the first difference - a 'diff' runs through the files completely.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-14-2009 05:00 AM
тАО05-14-2009 05:00 AM
Re: Help ksh script
Unix operates with beer.