- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script help for omni.
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
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
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-05-2011 09:12 AM
08-05-2011 09:12 AM
I am trying to write a script wherein I want to initialize two nearest date protected tape from current date for the fields as below:
root):/home/root#omnimm -list_pool Development
Status Medium Label Location Full Protected
===============================================================================
Good [NFC777L2] Development [HP:MSL6000 Series: 25] Yes 08/06/11 - initialize via script
Good [NFC774L2] Development [HP:MSL6000 Series: 22] Yes 08/14/11
Good [NFC773L2] Development [HP:MSL6000 Series: 24] Yes 08/07/11 - initialize via script
Good [NFC784L2] Development [HP:MSL6000 Series: 23] Yes 08/13/11
Good [NFC787L2] Development [HP:MSL6000 Series: 26] No 08/14/11
I will initialize the script on friday so if the date is Aug 5 then the nearest date are 08/06 and 08/07 then these should be initialized by command "omnimm -recycle"
I got the two fields by awk and sed as below:
NFC777L2 08/06/11
NFC774L2 08/14/11
NFC773L2 08/07/11
NFC784L2 08/13/11
NFC787L2 08/14/11
I am trying to take nearest two days with respect to current date and initializ it via script but not sure how to put them in action. Any suggestion would be highly helpful.
Thanking you in advance.
Solved! Go to Solution.
- Tags:
- date arithmetic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2011 09:30 AM - edited 08-05-2011 09:35 AM
08-05-2011 09:30 AM - edited 08-05-2011 09:35 AM
Re: Script help for omni.
Hi:
How about something as simple as this
# awk '{print $2,$1}' file | sort -t"/" -nk1,1 -nk2,2 | head -2
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2011 09:31 AM
08-05-2011 09:31 AM
Re: Script help for omni.
Ideally you would use a language that supports date arithmetic like perl. Then you can sort and pick the closest two.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2011 09:35 AM
08-05-2011 09:35 AM
Re: Script help for omni.
(root):/var/scripts#sort -t"/" -nk1,1 -nk2,2 list.final Usage: sort [-AbcdfiMmnru] [-T Directory] [-tCharacter] [-y kilobytes] [-o File] [-k Keydefinition].. [[+Position1][-Position2]].. [-z recsz] [File]..
Not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2011 09:36 AM
08-05-2011 09:36 AM
Re: Script help for omni.
Not good in perl.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2011 09:40 AM
08-05-2011 09:40 AM
Re: Script help for omni.
>sort -t"/" -nk1,1 -nk2,2 list.final
It probably doesn't like the -n before the -k: sort -t"/" -k1,1n -k2,2n list.final
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2011 09:40 AM
08-05-2011 09:40 AM
Re: Script help for omni.
@kampatel wrote:(root):/var/scripts#sort -t"/" -nk1,1 -nk2,2 list.final Usage: sort [-AbcdfiMmnru] [-T Directory] [-tCharacter] [-y kilobytes] [-o File] [-k Keydefinition].. [[+Position1][-Position2]].. [-z recsz] [File]..
Not working
Hi (again):
For HP-UX that should be:
# awk '{print $2,$1}' file | sort -t"/" -kk1,1 -kn2,2 | head -2
...though reversing the 'k' and 'n' options works on Apple :-)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2011 09:42 AM
08-05-2011 09:42 AM
Re: Script help for omni.
root):/var/scripts#awk '{print $2,$1}' list.final | sort -t"/" -kk1,1 -kn2,2 | head -2
Usage: sort [-AbcdfiMmnru] [-T Directory] [-tCharacter] [-y kilobytes] [-o File]
[-k Keydefinition].. [[+Position1][-Position2]].. [-z recsz] [File]..
Sorry, Not working again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2011 09:44 AM - edited 08-05-2011 09:50 AM
08-05-2011 09:44 AM - edited 08-05-2011 09:50 AM
Re: Script help for omni.
>For HP-UX that should be: ... | sort -t"/" -kk1,1 -kn2,2
sort(1) says that the type is after the field start or end: field_start [ type ] [,field_end [ type ] ]
Unless you want to use the global -n: sort -t"/" -n -k1,1 -k2,2 list.final
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-05-2011 09:45 AM
08-05-2011 09:45 AM
Re: Script help for omni.
@kampatel wrote:root):/var/scripts#awk '{print $2,$1}' list.final | sort -t"/" -kk1,1 -kn2,2 | head -2
Usage: sort [-AbcdfiMmnru] [-T Directory] [-tCharacter] [-y kilobytes] [-o File]
[-k Keydefinition].. [[+Position1][-Position2]].. [-z recsz] [File]..
Sorry, Not working again.
Yes, and I can't type :-)
# awk '{print $2,$1}' file | sort -t"/" -kn1,1 -kn2,2 | head -2
...not '-kk' as you copied from my mangled post.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2011 03:42 AM