- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Problem with expression within ksh script.
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-21-2002 12:04 PM
08-21-2002 12:04 PM
I have been beating myself against the wall with this script of mine for several days. I feel as though i am in the home stretch but I need some help on a few things with it.
1) It seems as though the YDATE variable near the top of the script is not functioning at all by the error i am getting from the expr, any clues there. I have to leave the DATE variable in the current format to match the date fields in my output file.
2) It also seems as though my HTML is not producing a line by line report but more rather a one line report all the way across the screen. If you take the output file attached here and open it with IE you will see what i am having as output. I need to make it so it reports each line as a new line on the report.
TY in advance.
fg.
mmdcux17@/home/fgrosb01# ./bpdbjobs.output
#!/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 +%m/%d/%Y`
FDATE=`date +%m%d%Y`
YDATE=`expr $DATE - 1`
expr: An integer value was expected.
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}/${FDATE}.fullnbujobsreport
TMP_FILE=${BASEDIR}/${FDATE}.tmpnbujobsreport
OUTPUT_FILE=${BASEDIR}/${FDATE}.nbujobsreport
echo $SCRIPT_SYSTEM \(Version $SCRIPT_REVISION\) $SCRIPT_EXECUTION_TIME
HP-UX (Version HPUX-b.11.00.01) 2002/08/21/15:45:30
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 'BEGIN{
print "
print "";
print "
jobid | jobtype | client | class | schedule | server | status | started}; { 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 |
print "";
}' >${TMP_FILE}
grep -i ${DATE} ${TMP_FILE} > ${OUTPUT_FILE}
grep -i ${YDATE} ${TMP_FILE} >> ${OUTPUT_FILE}
cat ${OUTPUT_FILE} | $MAIL -s "Netbackup Jobs Report ${SCRIPT_EXECUTION_TIME}" $ADDRESS
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 12:14 PM
08-21-2002 12:14 PM
SolutionDATE=`date +%m/%d/%Y`
YDATE=`expr $DATE - 1`
If you want to compute yesterdays date, then
look into a routine called "caljd.sh". It is a handy script for doing date computations.
Do a search within the forum and you should be able to find it.
Good Luck.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 12:15 PM
08-21-2002 12:15 PM
Re: Problem with expression within ksh script.
08/21/2002 - 1
Any chance you can use the caljd.sh script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 12:20 PM
08-21-2002 12:20 PM
Re: Problem with expression within ksh script.
Let's say that DATE = "08/20/2002". Just what is "08/20/2002" - 1? I suupose that you really want yesterday's date in that format.
Look for a thread "Yesterday's Date" that was posted yesterday and today in this Forum.
The basic idea is this
YDATE=$(caljd.sh -S "/") $(caljd.sh -p 1))
Invoke caljd.sh -u for a full usage.
You can find caljd.sh in the mentioned thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 12:20 PM
08-21-2002 12:20 PM
Re: Problem with expression within ksh script.
in the tables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 12:23 PM
08-21-2002 12:23 PM
Re: Problem with expression within ksh script.
YDATE=$(caljd.sh -S "/" $(caljd.sh -p 1))
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 12:30 PM
08-21-2002 12:30 PM
Re: Problem with expression within ksh script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 12:42 PM
08-21-2002 12:42 PM
Re: Problem with expression within ksh script.
For HTML code, their has to be a balance of tags. Here is a sample template showing the tags with their corresponding end-tags.
__
____
__
__
____
... | ... | ...
... | ... | ...
__
Ignore the "_", I had those in for indentation purposes only. As you can see has a at the end,
http://freespace.virgin.net/sizzling.jalfrezi/iniframe.htm
For help with using HTML codes.
Good Luck
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 03:48 PM
08-21-2002 03:48 PM
Re: Problem with expression within ksh script.
Frank,
Sorry, but I don't see an attachment???? Is it there? I have mozilla 1.1 and IE 6+ and neither see it.
In the BEGIN paragraph, the line:
print "jobidjobtypeclientclassscheduleserverstatusstarted
needs to have ;
The date stuff I think the others have nailed.
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2002 03:54 PM
08-21-2002 03:54 PM
Re: Problem with expression within ksh script.
Can you post the script as an attachment?? Maybe in another thread???
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2002 05:39 AM
08-22-2002 05:39 AM
Re: Problem with expression within ksh script.
YEAR=`date +%Y`
DDMM=`date +%d/%m/`
YEAR=$(( $YEAR - 1 ))
YDATE="$DDMM$YEAR"
For the HTML output try opening it with Amaya available
from http://www.w3c.org. It should identify your HTML
problem.
You could also upload the file to the validator at the same
site.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2002 10:53 AM
08-22-2002 10:53 AM
Re: Problem with expression within ksh script.
#Without Mints.
DATE=`date +%x` # Today's Date
YDATE=`TZ=CST+24 date +%x` # Yesterday's Date
echo "Today's Date :$DATE"
echo "Yesterday's Date :$YDATE"
#With Mints.
DATE=`date +%x" "%X` # Today's Date
YDATE=`TZ=CST+24 date +%x`" "`date +%X` # Yesterday's Date
echo "Today's Date :$DATE"
echo "Yesterday's Date :$YDATE"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2002 02:24 PM
08-22-2002 02:24 PM
Re: Problem with expression within ksh script.
For your date problem. Look no further but the attached script date2julian is extremly handy and it even knows when its eap year. So write your script to use this convertor and forget about it.
===================
here is how to use it
========================
BIN=/usr/local/bin
DT=`date +%D`
echo "$DT\nq" | $BIN/logDate2julian | awk '{print $9}' | read DATE
echo "$DT" | sed "s/\// /gp" | read M D Y # todays date
(( YESTERDAY= $DATE - 1 ))
echo "$YESTERDAY\nq\n" | $BIN/logDate2julian | awk '{print $7}' | read ETAD
echo "$ETAD" | sed "s/\// /gp" | read MM DD YY # yesterdays date
=========================
you can step back any amount of day you desire.
enjoy
Donny