- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need help in Shell scripting
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
тАО08-27-2006 05:42 PM
тАО08-27-2006 05:42 PM
I just born new in Shell scripting., I gota to know, If Im giving "cal 7 1950", it should gimme the number of days in that calender.
Anyways please..
WH..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2006 06:17 PM
тАО08-27-2006 06:17 PM
Re: Need help in Shell scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2006 06:18 PM
тАО08-27-2006 06:18 PM
Re: Need help in Shell scripting
and you see all month's of day of the year
1950
Good Luck,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2006 06:27 PM
тАО08-27-2006 06:27 PM
Re: Need help in Shell scripting
I need a script/command/function(interactive), using which, If I give the "Month and Year" as input, I should just give the output as "The month/Yr which you have typed has got XY days"...I just need the number of days, if I give any month/yr..
WH..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2006 06:57 PM
тАО08-27-2006 06:57 PM
Re: Need help in Shell scripting
baan01:/#date
Mon Aug 28 10:01:44 EETDST 2006
## Work out what yesterday's date was
if [ "${DAY}" = "01" ]
then
case ${MTH} in
Jan)SEARCH_MTH=Dec;((SEARCH_YEAR=YEAR-1));SEARCH_DAY=31;
;
Feb)SEARCH_MTH=Jan;SEARCH_YEAR=${YEAR};SEARCH_DAY=31;;
Mar)SEARCH_MTH=Feb;SEARCH_YEAR=${YEAR};SEARCH_DAY=28;;
Apr)SEARCH_MTH=Mar;SEARCH_YEAR=${YEAR};SEARCH_DAY=31;;
May)SEARCH_MTH=Apr;SEARCH_YEAR=${YEAR};SEARCH_DAY=30;;
Jun)SEARCH_MTH=May;SEARCH_YEAR=${YEAR};SEARCH_DAY=31;;
Jul)SEARCH_MTH=Jun;SEARCH_YEAR=${YEAR};SEARCH_DAY=30;;
Aug)SEARCH_MTH=Jul;SEARCH_YEAR=${YEAR};SEARCH_DAY=31;;
Sep)SEARCH_MTH=Aug;SEARCH_YEAR=${YEAR};SEARCH_DAY=31;;
Oct)SEARCH_MTH=Sep;SEARCH_YEAR=${YEAR};SEARCH_DAY=30;;
Nov)SEARCH_MTH=Oct;SEARCH_YEAR=${YEAR};SEARCH_DAY=31;;
Dec)SEARCH_MTH=Nov;SEARCH_YEAR=${YEAR};SEARCH_DAY=30;;
esac
else
SEARCH_MTH=${MTH}
SEARCH_YEAR=${YEAR}
((SEARCH_DAY=DAY-1))
if [ "${SEARCH_DAY}" -lt "10" ]
then
SEARCH_DAY="0${SEARCH_DAY}"
fi
fi
ONE_DAY_BACK="${SEARCH_YEAR}-${SEARCH_MTH}-${SEARCH_DAY}"
TODAY="${SEARCH_YEAR}-${SEARCH_MTH}-${DAY}"
OR;
How to schedule a job on last friday;
## get actual day
DAY=`date +"%d"`
## get the last friday of curren month
EXEC_DAY=`cal | awk 'NF >=6 { last = $6 }; END{ print last }'`
if [ $DAY -ne $EXEC_DAY ]
then
echo " - Not run because is not the last friday - "
exit;
fi
## Here must write your script
## your commands
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2006 07:13 PM
тАО08-27-2006 07:13 PM
Re: Need help in Shell scripting
Jan)SEARCH_MTH=Dec;((SEARCH_YEAR=YEAR-1));SEARCH_DAY=31;;
Feb)SEARCH_MTH=Jan;SEARCH_YEAR=${YEAR};SEARCH_DAY=31;;
In the above sample lines of yours, from wheres the ${YEAR} taken from..?
WH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2006 07:17 PM
тАО08-27-2006 07:17 PM
Re: Need help in Shell scripting
DAY=`date +%d`
MTH=`date +%m`
YEAR=`date +%Y`
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-27-2006 07:20 PM
тАО08-27-2006 07:20 PM
Re: Need help in Shell scripting
baan01:/#DAY=`date +%d`
baan01:/#echo $DAY
28
baan01:/#MTH=`date +%m`
baan01:/#echo $MTH
08
baan01:/#YEAR=`date +%Y`
baan01:/#echo $YEAR
2006
baan01:/#
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2006 07:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2006 08:08 PM
тАО08-28-2006 08:08 PM
Re: Need help in Shell scripting
you can use:
#/user/bin/ksh
# day_of_month
MM=${1:-$(date +%m)}
YYYY=${2:-$(date +%Y)}
TEMP=$(cal $MM $YYYY)
DAYS=$(echo $TEMP|awk '{print $NF}')
echo "$MM $YYYY has $DAYS"
#eof
day_of_month
08 2006 has 31
day_of_month 7 1950
7 1950 has 31
it runs fine on hp hp-ux 11i. (It take care leap years of course).
HTH,
Art