- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: cksum 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
Forums
Discussions
Discussions
Discussions
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
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
07-17-2005 08:43 PM
07-17-2005 08:43 PM
I am experiencing a truncation issue with some files that I ftp from one server to another. I know that I can resolve this issue by writing a cksum script which will resend the file if the cksum doesn't match.
Does anyone have a convenient script that can do this using 'cksum'?
Cheers,
D
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2005 08:57 PM
07-17-2005 08:57 PM
Solution#!/bin/ksh
index=0
get_file()
{
ftp -i -n localhost <
bin
get $1
bye
EOF
}
for file in `ls`
do
cksum $file >/dev/null
if [[ $? -ne 0 ]]
then
echo "$file is having problem. Have to be refetched again"
ERROR_FILE[$index]=$file;
let index=index+1
fi
done
index=0
while [[ $index -lt ${#ERROR_FILE[*]} ]]
do
get_file ${ERROR_FILE[$index]}
let index=index+1
done
Organize and change this script to your requirement.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2005 09:26 PM
07-17-2005 09:26 PM
Re: cksum script
#!/bin/ksh
# Variable
SUCCESS=0
# USER Input: Give correct input for this
REMOTE_MACHINE="localhost"
USERNAME="root"
PASSWD="emclegato"
REMOTE_DIRECTORY=""
LOCAL_DIRECTORY=""
# Function part
get_file()
{
ftp -i -n $REMOTE_MACHINE<
bin
cd $REMOTE_DIRECTORY
lcd $LOCAL_DIRECTORY
mget *
bye
EOF
}
# END get_file
check_status()
{
index=0
set -A ERROR_FILE ""
for file in `ls $LOCAL_DIRECTORY/*`
do
cksum $file 1>/dev/null 2>&1
if [[ $? -ne 0 ]]
then
ERROR_FILE[$index]=$file
let index=index+1
fi
done
if [[ -z ${ERROR_FILE} ]]
then
let SUCCESS=1
fi
}
# Main code #
while [[ $SUCCESS -ne 1 ]]
do
get_file
check_status
done
exit 0
# END #
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2005 12:35 AM
07-18-2005 12:35 AM
Re: cksum script
I have noticed that this script only performs the checksum at the source.
I require the source checksum to be ftp'ed to the destination server along with the file and another checksum performed on the ftp'ed file at the destination server before comparing the two checksums and sending an err msg if the 2 cksum's are not identical.
Dermot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2005 07:08 PM
07-18-2005 07:08 PM
Re: cksum script
1. cksum file > source.txt
result = 1
while result = 0
do
2. ftp the file
3. remsh destinationhost "cksum file" > destination.txt
4. diff source.txt destination.txt
5. result = $?
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2005 07:49 PM
07-18-2005 07:49 PM
Re: cksum script
If you have telnet support to remote machine, we can do it with that also as,
(
sleep 1;
printf "$USERNAME\n";
sleep 1;
printf "$PASSWD\n";
sleep 1;
<script can be executed to get cksum in remote machine>
sleep 1;
printf "exit;"
) | telnet
It will work. give time to make script with this.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2005 07:55 PM
07-18-2005 07:55 PM
Re: cksum script
Thanks for the suggestions lads but unfortunately the only connection that is permitted between the 2 servers is ssh and ftp.
D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2005 09:05 PM
07-18-2005 09:05 PM
Re: cksum script
#!/bin/ksh
# Variable
SUCCESS=0
# USER Input: Give correct input for this
REMOTE_MACHINE="localhost"
USERNAME="root"
PASSWD="emclegato"
REMOTE_DIRECTORY=""
LOCAL_DIRECTORY=""
# Authentication
auth_server()
{
(
sleep 1;
printf "$USERNAME\n";
sleep 1;
printf "$PASSWD\n";
sleep 1;
printf "cd $REMOTE_DIRECTORY;find . -type f -exec cksum {} \; 1>cksum.log\n";
sleep 1;
printf "exit;"
) | telnet ${REMOTE_MACHINE}
# Function part
get_file()
{
ftp -i -n $REMOTE_MACHINE<
bin
cd $REMOTE_DIRECTORY
lcd $LOCAL_DIRECTORY
mget *
bye
EOF
}
# END get_file
# Main
auth_server
get_file
# Checksum comparision
cd $LOCAL_DIRECTORY
find . ! -name cksum.log -type f -exec cksum {} \; 1>cksum.log.new
diff -q cksum.log.new cksum.log | grep -q 'differ'
if [[ $? -eq o ]]
then
echo "File transfer was successful"
else
echo "File transfer was not successful"
fi
exit 0
# END #
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-18-2005 09:14 PM
07-18-2005 09:14 PM
Re: cksum script
You could use ssh to get the cksum from the source:
cksum=`ssh source "cksum /path/to/file"`
You'll need to setup SSH publickey-authorization in order to use it without interaction.
http://newfdawg.com/SHP-SSHpart2.htm
Cheers