- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- massaging an output file into a readable format.
Operating System - HP-UX
1755605
Members
5015
Online
108836
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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-20-2002 10:51 AM
тАО08-20-2002 10:51 AM
All
I am running a script that has an output file which when generated list all my backups, this part of it all works the way I want it to.
The problem I have with the attached file is 2 fold:
1) I want to massage the file into neat readable collumns.
2) I want to wrap the file in HTML and then email it out.
Can any of you help me here. I am listing the script here and attaching the output file.
Thanks in advance.
FG
#!/usr/bin/ksh -v
#
# This script is being developed to provide a detailed report of the previous day's backup
# jobs from netbackup. This script will be executed daily at 10:00AM.
# Upon successful completion, the output from this script will be webified using html and then
# emailed to the it_backup_admins mailing list.
#
# This script must be executed utlizing the root user account.
# Environmental section
set -u
BASEDIR=/home/fgrosb01
DATE=`date +%Y%m%d`
SCRIPT_REVISION="HPUX-b.11.00.01"
SCRIPT_HPUX_VERSION=$(uname -r)
SCRIPT_SYSTEM=$(uname - n)
SCRIPT_USER=$(whoami)
SCRIPT_EXECUTION_TIME=$(date +'%Y/%m/%d/%H:%M:%S')
MAIL=/usr/bin/mailx
ADDRESS="frank.grosberger@chsli.org"
INPUT_FILE=${BASEDIR}/${DATE}.fullnbujobsreport
OUTPUT_FILE=${BASEDIR}/${DATE}.nbujobsreport
echo ${SCRIPT_SYSTEM} \(Version ${SCRIPT_REVISION}\) ${SCRIPT_EXECUTION_TIME}
echo _____________________________________________________________________
echo
if [ ${SCRIPT_USER} != "root" ] ; then
echo
echo "This program must be executed utilizing the root logon id only"
echo
return 501
fi
echo _______________________________________________________________________
###########################################################################
#
# This section of the script will execute the bpdbjobs command utilizing
# the file /home/fgrosb01/.xbpmonrcfg as it's configuration file for the
# output.
bpdbjobs -header -report -format ${BASEDIR}/.xbpmonrcfg > ${INPUT_FILE}
cat ${INPUT_FILE} | awk '{
jobid=substr($0,1,10);
jobtype=substr($0,12,11);
jobstate=substr($0,24,8);
status=substr($0,33,8);
class=substr($0,42,27);
schedule=substr($0,70,18);
client=substr($0,89,26);
mediaserver=substr($0,116,26);
started=substr($0,143,21);
elapsed=substr($0,165,14);
ended=substr($0,180,21)
Kbytes=substr($0,202,13);
files=substr($0,216,13);
compestimated=substr($0,230,11);
printf("%s%s%s%s%s%s%s%s%s%s%s\n",jobid,jobtype,client,class,schedule,
server,started,ended,Kbytes,files,compestimated);
}' > ${OUTPUT_FILE}
cat ${OUTPUT_FILE} | $MAIL -s "Netbackup Jobs Report ${SCRIPT_EXECUTION_TIME}" $ADDRESS
exit 0
I am running a script that has an output file which when generated list all my backups, this part of it all works the way I want it to.
The problem I have with the attached file is 2 fold:
1) I want to massage the file into neat readable collumns.
2) I want to wrap the file in HTML and then email it out.
Can any of you help me here. I am listing the script here and attaching the output file.
Thanks in advance.
FG
#!/usr/bin/ksh -v
#
# This script is being developed to provide a detailed report of the previous day's backup
# jobs from netbackup. This script will be executed daily at 10:00AM.
# Upon successful completion, the output from this script will be webified using html and then
# emailed to the it_backup_admins mailing list.
#
# This script must be executed utlizing the root user account.
# Environmental section
set -u
BASEDIR=/home/fgrosb01
DATE=`date +%Y%m%d`
SCRIPT_REVISION="HPUX-b.11.00.01"
SCRIPT_HPUX_VERSION=$(uname -r)
SCRIPT_SYSTEM=$(uname - n)
SCRIPT_USER=$(whoami)
SCRIPT_EXECUTION_TIME=$(date +'%Y/%m/%d/%H:%M:%S')
MAIL=/usr/bin/mailx
ADDRESS="frank.grosberger@chsli.org"
INPUT_FILE=${BASEDIR}/${DATE}.fullnbujobsreport
OUTPUT_FILE=${BASEDIR}/${DATE}.nbujobsreport
echo ${SCRIPT_SYSTEM} \(Version ${SCRIPT_REVISION}\) ${SCRIPT_EXECUTION_TIME}
echo _____________________________________________________________________
echo
if [ ${SCRIPT_USER} != "root" ] ; then
echo
echo "This program must be executed utilizing the root logon id only"
echo
return 501
fi
echo _______________________________________________________________________
###########################################################################
#
# This section of the script will execute the bpdbjobs command utilizing
# the file /home/fgrosb01/.xbpmonrcfg as it's configuration file for the
# output.
bpdbjobs -header -report -format ${BASEDIR}/.xbpmonrcfg > ${INPUT_FILE}
cat ${INPUT_FILE} | awk '{
jobid=substr($0,1,10);
jobtype=substr($0,12,11);
jobstate=substr($0,24,8);
status=substr($0,33,8);
class=substr($0,42,27);
schedule=substr($0,70,18);
client=substr($0,89,26);
mediaserver=substr($0,116,26);
started=substr($0,143,21);
elapsed=substr($0,165,14);
ended=substr($0,180,21)
Kbytes=substr($0,202,13);
files=substr($0,216,13);
compestimated=substr($0,230,11);
printf("%s%s%s%s%s%s%s%s%s%s%s\n",jobid,jobtype,client,class,schedule,
server,started,ended,Kbytes,files,compestimated);
}' > ${OUTPUT_FILE}
cat ${OUTPUT_FILE} | $MAIL -s "Netbackup Jobs Report ${SCRIPT_EXECUTION_TIME}" $ADDRESS
exit 0
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2002 11:03 AM
тАО08-20-2002 11:03 AM
Solution
You could embed the necessary html code as part of the output file.
Here is your awk script with html inserted.
cat ${INPUT_FILE} | awk '{
BEGIN{
print "Backup List ";
print "";
print "\n";
";
print ""
' > ${OUTPUT_FILE}
hope this helps...
-- Rod Hills
Here is your awk script with html inserted.
cat ${INPUT_FILE} | awk '{
BEGIN{
print "
print "";
print "
Title Field1 | Title Field2 | ...repeat for each title";%sa | %s | %s | %s | %s | %s | %s | %s | %s | %s | %s | \n",jobid,jobtype,client,class,schedule,
print ""
' > ${OUTPUT_FILE}
hope this helps...
-- Rod Hills
There be dragons...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2002 05:26 PM
тАО08-20-2002 05:26 PM
Re: massaging an output file into a readable format.
Hi Frank,
I am not sure if I understood your requirement. Your output does seem readable. If you want to strip out some of the columns, you can easily do it using awk. Job id is column 1, job type is column 2, clinet col 3 etc., If you want to print only Job id, Client, Schedule, Start time (col 6 and 7) and End time (col 8 and 9), then you would keep an awk statement as below.
.......
bpdbjobs -header -report -format ${BASEDIR}/.xbpmonrcfg > ${INPUT_FILE}
cat ${INPUT_FILE} |awk '{print $1,$3, $5,$6, $7, $8, $9}' >> ${OUTPUT_FILE}
#Put it in html format
cat << EOF >> ${OUTPUT_FILE}.html
EOF
.......
If you want more columns, you can add the corresponding column number to $variable in the first awk column.
I hope this helps you,
-Sri
I am not sure if I understood your requirement. Your output does seem readable. If you want to strip out some of the columns, you can easily do it using awk. Job id is column 1, job type is column 2, clinet col 3 etc., If you want to print only Job id, Client, Schedule, Start time (col 6 and 7) and End time (col 8 and 9), then you would keep an awk statement as below.
.......
bpdbjobs -header -report -format ${BASEDIR}/.xbpmonrcfg > ${INPUT_FILE}
cat ${INPUT_FILE} |awk '{print $1,$3, $5,$6, $7, $8, $9}' >> ${OUTPUT_FILE}
#Put it in html format
cat << EOF >> ${OUTPUT_FILE}.html
%s | " $TD >> ${OUTPUT_FILE}.html
EOF
.......
If you want more columns, you can add the corresponding column number to $variable in the first awk column.
I hope this helps you,
-Sri
You may be disappointed if you fail, but you are doomed if you don't try
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-20-2002 05:29 PM
тАО08-20-2002 05:29 PM
Re: massaging an output file into a readable format.
Hi (again),
Forgot to clarify. ${OUTPUT_FILE} is the simple ascii output and ${OUTPUT_FILE).html is the html output. You can add the other lines of script to it like add additional headers, send mail etc.,
-Sri
Forgot to clarify. ${OUTPUT_FILE} is the simple ascii output and ${OUTPUT_FILE).html is the html output. You can add the other lines of script to it like add additional headers, send mail etc.,
-Sri
You may be disappointed if you fail, but you are doomed if you don't try
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP