- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Restart a function if it gets aborted during t...
Operating System - Linux
1752808
Members
6700
Online
108789
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО10-21-2007 05:35 AM
тАО10-21-2007 05:35 AM
Re: Restart a function if it gets aborted during the excution of script
Hi (again) Raghu:
Since the code I presented is destructive to the argument list (the 'shift') we need to preserve the original argument list and then process it, in another pass, if its elements are valid.
The following modification might be useful to you.
# cat ./parse
#!/usr/bin/sh
typeset -i MAX=$#-1
typeset -i N=0
if [ $# -eq 0 ]; then
STEP=0
echo "no arguments; use file"
else
set -A STEPS $@
while (( $# > 0 ))
do
STEP=$1
shift
if [ `expr "${STEP}" : '[0-9]*'` -ne `expr "${STEP}" : '.*'` ]; then
echo "ERROR: STEP must be a number; scanning: ${STEP}"
exit 1
fi
echo "STEP-${STEP} requested"
done
fi
N=0
while (( N <= MAX ))
do
echo "now processing STEP-${STEPS[$N]}"
let N=N+1
done
exit 0
Note that the script's value of 'MAX' is established to be zero-relative, since elements of an array ('STEPS') are referenced with zero as the first element.
Regards!
...JRF...
Since the code I presented is destructive to the argument list (the 'shift') we need to preserve the original argument list and then process it, in another pass, if its elements are valid.
The following modification might be useful to you.
# cat ./parse
#!/usr/bin/sh
typeset -i MAX=$#-1
typeset -i N=0
if [ $# -eq 0 ]; then
STEP=0
echo "no arguments; use file"
else
set -A STEPS $@
while (( $# > 0 ))
do
STEP=$1
shift
if [ `expr "${STEP}" : '[0-9]*'` -ne `expr "${STEP}" : '.*'` ]; then
echo "ERROR: STEP must be a number; scanning: ${STEP}"
exit 1
fi
echo "STEP-${STEP} requested"
done
fi
N=0
while (( N <= MAX ))
do
echo "now processing STEP-${STEPS[$N]}"
let N=N+1
done
exit 0
Note that the script's value of 'MAX' is established to be zero-relative, since elements of an array ('STEPS') are referenced with zero as the first element.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2007 08:19 AM
тАО10-21-2007 08:19 AM
Re: Restart a function if it gets aborted during the excution of script
>JRF: set -A STEPS $@
If you want perfection on saving and restoring, you should quote the parms:
set -A STEPS "$@"
If you want perfection on saving and restoring, you should quote the parms:
set -A STEPS "$@"
- Tags:
- set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2007 09:49 AM
тАО10-21-2007 09:49 AM
Re: Restart a function if it gets aborted during the excution of script
Hi (again):
Dennis>: If you want perfection on saving and restoring, you should quote the parms:
set -A STEPS "$@"
Agreed, although in the context I suggested the argument list, there would be no need to supply it in quotes like "4 5 6" 7 8 versus "4 5 6 7 8" versus 4 5 6 7 8 (without any quotes. Your point is noted, though. Thanks.
Regards!
...JRF...
Dennis>: If you want perfection on saving and restoring, you should quote the parms:
set -A STEPS "$@"
Agreed, although in the context I suggested the argument list, there would be no need to supply it in quotes like "4 5 6" 7 8 versus "4 5 6 7 8" versus 4 5 6 7 8 (without any quotes. Your point is noted, though. Thanks.
Regards!
...JRF...
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP