- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need help with a script (fixing some formatting)
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
01-29-2003 06:22 PM
01-29-2003 06:22 PM
which will be used to create pipe separated files that will later be imported into Oracle
database tables. This is to facilitate reading and viewing to some managers who want to
look at system access info using some interface repots through access or something like
that.
Well, most of the the script's syntax I am using is included in my next posting as an
attachment. Where I need help is with the formatting that takes place with what
I get with "lastb -R", attached is a detailed explanation of my dilemma.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 06:34 PM
01-29-2003 06:34 PM
Re: Need help with a script (fixing some formatting)
Oh, and let me toss another question, you may see the vi command I used in the script. What I was trying to do there was eliminate the very last line of the of the files because it was coming out blank and I did not need it. How can I remove the last line of a file (no matter how many lines it has and I won't know -- well, I could know using wc?)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 06:42 PM
01-29-2003 06:42 PM
Re: Need help with a script (fixing some formatting)
will exclude all blank line.
You script is too big to read for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 06:45 PM
01-29-2003 06:45 PM
Re: Need help with a script (fixing some formatting)
I think you can take care of your lastb problem a couple of different ways. Take a look at the 'cut' command. You can specify columns for cutting with that command so you should be able to specify a field. Or, you could use awk and the substr function to break out the strings. Probably the best way to do it would be with Perl. I think there might even be a Perl module that reads the last and lastb information from wtmp/btmp for you.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 06:48 PM
01-29-2003 06:48 PM
Re: Need help with a script (fixing some formatting)
To eliminate the last line of the file, do this:
# sed -e '$d' infile > outfile
As far as the login name containing blanks, I'd suggest you unconditionally treat the extent of the first field as 8-characters (which should be the maximum for a login name) and then proceed to reformat with pipe characters.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 07:42 PM
01-29-2003 07:42 PM
Re: Need help with a script (fixing some formatting)
Below is a simple script that does a lastb -R and outputs into result as a comma seperated file.
lastb -R |sed 's/ /#/g' |while read line
do
USER=$(echo $line|cut -c 1-8)
CHOPPED=$(echo $line|sed 's/'$USER'/ /g'|sed 's/#/ /g')
FIRST=$(echo $USER|sed 's/#/ /g')
PTS=$(echo $CHOPPED|awk '{print $1}')
SYS=$(echo $CHOPPED|awk '{print $2}')
echo "$FIRST,$PTS,$SYS" >> result
done
The trick here is to replace blanks with a special character, cut first 8 chars, remove them from the line and use awk to seperate the fields and then replace the character back with a space. So, this script may give wrong results if that character is originally part of the failed login.
But you can use similar logic to achieve what you need.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2003 10:09 PM
01-29-2003 10:09 PM
Re: Need help with a script (fixing some formatting)
you can use awk and counting the fields not from the beginnig but from the end:
# cat inputfile
a b c d e
a c d e
# awk '{printf("%s %s\n",$(NF-1),$NF)}' inputfile
d e
d e
#
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2003 02:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2003 09:15 AM
01-31-2003 09:15 AM
Re: Need help with a script (fixing some formatting)
Thanks everyone for your participation!