- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Function within a script not working
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
02-26-2004 10:08 AM
02-26-2004 10:08 AM
Attached is a script which I am trying to verify the date entered DDMM has been entered correctly but I cannot get the sytax correct.
please help
thnx
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2004 10:10 AM
02-26-2004 10:10 AM
Re: Function within a script not working
ty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2004 10:13 AM
02-26-2004 10:13 AM
Re: Function within a script not working
'date +%d%m' inside sed will be treated as a string.
cat $i |sed s/'date +%d%m'/$SPFCHANGE/g >tmpfile
Modify the above as follows
DATE=$(date +%d%m)
sed 's/'${DATE}'/'$SPFCHANGE'/g' $i > tmpfile
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2004 10:15 AM
02-26-2004 10:15 AM
Re: Function within a script not working
I should have explained, the part that isn't working is the test to check the date (the commented line)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2004 10:21 AM
02-26-2004 10:21 AM
Solutioncase $SPFCHANGE in
[0-9][0-9][0-9][0-9]) call_your_function
;;
*) echo "There has been a problem changing the date, please check the date format" ; exit 1
;;
esac
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2004 10:23 AM
02-26-2004 10:23 AM
Re: Function within a script not working
what about:
case $SPFCHANGE in
[0-9][0-9][0-9][0-9]) for i in ...
*) echo "There has been a problem changing the date, please check the date format" ;
exit;;
esac
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2004 10:23 AM
02-26-2004 10:23 AM
Re: Function within a script not working
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2004 10:37 AM
02-26-2004 10:37 AM
Re: Function within a script not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2004 10:47 AM
02-26-2004 10:47 AM
Re: Function within a script not working
OK=0
while [[ ${OK} -eq 0 ]]
do
echo "Please enter the date of the file you wish to transfer (DDMM): \c"
read SPFCHANGE
echo ${SPFCHANGE} | awk '{if ($0 ~ /^[0-9]{4}$/) exit(1); else exit(0)}'
OK=${?}
if [[ ${OK} -eq 0 ]]
then
echo "\aBad format; re-enter"
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2004 11:57 AM
02-26-2004 11:57 AM
Re: Function within a script not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-01-2004 01:04 AM
03-01-2004 01:04 AM
Re: Function within a script not working
OK=0
typeset -i DD
typeset -i MM
while [[ ${OK} -eq 0 ]]
do
echo "Please enter the date of the file you wish to transfer (DDMM): \c"
read SPFCHANGE
echo ${SPFCHANGE} | awk '{if ($0 ~ /^[0-3][0-9][0-1][0-9]$/) exit(1); else exit(0)}'
OK=${?}
if [[ ${OK} -eq 0 ]]
then
echo "\aBad format; re-enter"
else
DD=`echo $SPFCHANGE | cut -c 1-2`
MM=`echo $SPFCHANGE | cut -c 3-4`
if [ ${DD} -gt 31 -o ${MM} -gt 12 ]
then
echo "\aBad format; re-enter"
OK=0
else
OK=1
fi
fi
done
Regards