- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script doubt
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
08-04-2009 11:11 AM
08-04-2009 11:11 AM
Below scripts provides login details for current date.
#!/bin/sh
date1=`date|awk '{print $2}'`
date2=`date|awk '{print $3}'`
hostname=`hostname`
grep -i sshd /var/adm/syslog/syslog.log|grep -i keyboard-interactive |grep "$date1 *$date2" |awk '{print $1" "$2"
"$3" "$9" "$11}'
Actually i want collect the details for previous date means yesterday's.
Plz help me to edit the script for the same.
regards
himacs
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2009 11:26 AM
08-04-2009 11:26 AM
Re: script doubt
YESTERDAY=$(TZ=$(date +%Z)+24; date '+%b %e')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2009 11:39 AM
08-04-2009 11:39 AM
SolutionPlaying +-24 hours with the TZ variable works only for UTC (GMT) timezones. You are better using a simple Perl snippet where this doesn't matter. That is, it is usable at anytime in your localtime:
# YESTERDAY=$(perl -MPOSIX -le 'print strftime "%b %e",localtime(time-(60*60*24))')
# echo "$YESTERDAY"
Aug 3
You can use any of the formatting directives you think about when you use the 'date' command. The '%e' specification yields the day of the month with space fill whereas the '%d' uses zero-fill.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2009 11:52 AM
08-04-2009 11:52 AM
Re: script doubt
thanx for ur replies.
James, i have used the script given by you.
Its worked fine.I got the desired output.full points assigned
But plz tell me whether we can use perl scripts in hpux?
$(perl -MPOSIX -le 'print strftime "%b %e",localtime(time-(60*60*24))')
as m new into scripting world, i have lot more doubts.
and plz suggest with document with basic scripting..
thanx once again for ur support..
regards
himacs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2009 12:02 PM
08-04-2009 12:02 PM
Re: script doubt
http://oreilly.com/catalog/9781565922846/
If you are asking about shell programming, another O'reilly book comes to mind, "Learning the Korn Shell":
oreilly.com/catalog/9780596001957
But there is no better way than learning it by trying it out on your own, preferably under a project deadline :)
Hope this helps
UNIX because I majored in cryptology...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2009 12:09 PM
08-04-2009 12:09 PM
Re: script doubt
> But plz tell me whether we can use perl scripts in hpux?
Absolutely! Perl is used by several tools within the HP-UX operating system; most notably by Bastille and SWA.
Perl has been installed with HP-UX for a long, time.
# swlist | grep -i perl
By default, perl lives in '/opt/perl' with a symbolic link from '/usr/bin/perl':
# whereis perl
The script I offered you is designed to be incorporated into a shell script. It gives the 'YESTERDAY' shell variable the month and day for yesterday in your timezone.
> and plz suggest with document with basic scripting.
Yes, you need to become somewhat fluent in shell scripting. In HP-UX the standard shell is the POSIX shell ('/usr/bin/sh' or '/sbin/sh' for root).
Closely related to the POSIX shell is the Korn (ksh) shell and the favorite of the Linux community, the Bash shell. They are similar, but on HP-UX use the POSIX shell. You must for root or you will render your system unstartable.
There are a number of good books on shell programming. A free guide is:
http://docs.hp.com/en/B2355-90046/index.html
...and a very nice resource is:
http://www.shelldorado.com/
Regards (and happy scripting!)
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2009 12:15 PM
08-04-2009 12:15 PM
Re: script doubt
Thanx for the suggestions..
As m started peeping into scripting world, u can expect more posts from me.:)
Jai ho itrc
regards
himacs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2009 05:56 PM
08-04-2009 05:56 PM
Re: script doubt
Perl is just one the hundreds of commands available in HP-UX. Commands like awk and sed and date are simply tools that can be called from any script (as you have with awk). You can learn Perl is great detail and write complete Perl-only scripts, but just like awk, you can accomplish a lot with simple one-liners.
Here are some 1-liners:
awk
http://www.catonmat.net/blog/awk-one-liners-explained-part-one/
Perl
http://www.ibm.com/developerworks/linux/library/l-p101/
Bill Hassell, sysadmin