- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Help to improve 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-27-2009 03:52 AM
тАО05-27-2009 03:52 AM
I have below script:
if [ "$x" != "0" ]; then
cat $y | while read LINE
do
cp -p $z${LINE} /eva/bulk/tmp/${LINE}
diff $z${LINE} /eva/bulk/tmp/${LINE}> /dev/null
if [ $? -eq 0 ]; then
gzip /eva/bulk/tmp/${LINE}
else
continue
fi
done
else echo "There are no files to be copied................."
fi
How to reexecute the cp command again with the same line that have diff not equal to zero??Please advice.Thanks in advanced.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2009 04:42 AM
тАО05-27-2009 04:42 AM
Re: Help to improve ksh script
if [ "$x" != "0" ]; then
cat $y | while read LINE
do
is_ok=1
until [ $is_ok -eq 0 ]; do
cp -p $z${LINE} /eva/bulk/tmp/${LINE}
diff $z${LINE} /eva/bulk/tmp/${LINE}> /dev/null
is_ok=$?
done
gzip /eva/bulk/tmp/${LINE}
else echo "There are no files to be copied"
fi
not tested it can be syntax problems.
Kenan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2009 02:53 PM
тАО05-27-2009 02:53 PM
Re: Help to improve ksh script
Did you see my response to your other thread?
http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1339591
You could use "cmp -s" instead of diff.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2009 07:50 PM
тАО05-27-2009 07:50 PM
Re: Help to improve ksh script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2009 10:17 PM
тАО05-27-2009 10:17 PM
Re: Help to improve ksh script
You could just test the exit status, "$?".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2009 10:18 PM
тАО05-27-2009 10:18 PM
SolutionExit status is normally 0; if an error occurs, exit status is 1. If a
warning occurs, exit status is 2.
you can check after gzip command
if [ $? -eq 0 ]; then
sucessfull
else
not successfull
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2009 12:21 AM
тАО05-28-2009 12:21 AM
Re: Help to improve ksh script
instead of:
if [ "$x" != "0" ]; then
cat $y | while read LINE
do
cp -p $z${LINE} /eva/bulk/tmp/${LINE}
diff $z${LINE} /eva/bulk/tmp/${LINE}> /dev/null
if [ $? -eq 0 ]; then
gzip /eva/bulk/tmp/${LINE}
else
continue
fi
done
better:
while read LINE
....
done <$y
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2009 12:22 AM
тАО05-28-2009 12:22 AM
Re: Help to improve ksh script
you can gzip -t for compressed file integrity. but again you must check return value by the script abowe if it returns 0.