- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script help
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
Forums
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
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
тАО10-08-2001 10:30 AM
тАО10-08-2001 10:30 AM
script help
#!/usr/bin/ksh
##################################################################
# Declare variables
PATH=/usr/bin:/usr/local/bin
SERVERS="/opt/data/all-servers"
PAGE="/opt/apache/htdocs/backups/test.html"
TMP_PAGE1="/tmp/list1.html"
TMP_PAGE2="/tmp/list2.html"
DATE=$(date)
COLOR=""
FAIL_CODE=""
END=""
# Make sure we start clean
/usr/bin/rm -f $TMP_PAGE1 $TMP_PAGE2
# Start the page
cat <<-EOF > $PAGE
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
Last updated: $DATE
NOTES:
This page is currently being built.
EOF
# Start the table
cat <<-EOF >> $PAGE
EOF # Get the data for i in `cat $SERVERS` xxxxx xxxxxxx do # Get the start time ssh $i "tail -2 /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep 'Started'" > $TMP_PAGE2 echo " " >> $TMP_PAGE2 echo $END >> $TMP_PAGE2 # Get the end time - will also use later for COLOR selection END=$(ssh $i "tail -2 /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep '^Completed'") echo " " >> $TMP_PAGE2 echo " | " >> $TMP_PAGE2 # Get the failure code and set the color FAIL_CODE=$(ssh $i "tail -1 /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep 'Ended' 'makrec.log1' | tail -2") case $FAIL_CODE in "Completed" ) COLOR="GREEN" ;; "Ended" ) COLOR="RED" ;; * ) COLOR="RED" ;; esac # Also set the COLOR based on $END [ $(echo $END | grep -c Ended) -eq 1 ] && COLOR="GREEN" # Build the first column - This is where we set the color echo " | ||
" > $TMP_PAGE1 echo "" >> $TMP_PAGE1 echo "$i | " >> $TMP_PAGE1 echo "" >> $TMP_PAGE1 echo " " >> $TMP_PAGE1 # Pull it together cat $TMP_PAGE1 $TMP_PAGE2 >> $PAGE done # end the table echo " |
echo "" >> $PAGE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2001 11:21 AM
тАО10-08-2001 11:21 AM
Re: script help
Few errors i found were,
1. In the start of the page, you are using a here-to doc, and using cat << -EOF but you are ending it with EOF, you might want to be consistent.
2. Same issue with start of table. Mismatch -EOF and EOF.
3. Getting the start time, you are doing a tail -2 and looking for start time, but it may not be available. you are better of doing
ssh $i "grep '^Started' /var/opt/ignite/logs/makrec.log1 2> /dev/null |tail -1" > $TMP_PAGE2
4. Same issue with FAIL_CODE, you want to grep for Ended and then look at the last entry.
One way to check is to print the values of the variables. echo "END is $END" etc.
-HTH
Ramesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2001 11:26 AM
тАО10-08-2001 11:26 AM
Re: script help
Also, what is the "grep 'Ended' 'makrec.log1' " supposed to do? "grep" will return with an error that it can't find "makrec.log1", unless you are in the /car/opt/ignite/logs directory.
FAIL_CODE=$(ssh $i "tail -1 /var/opt/ignite/logs/makrec.log1 2> /dev/null | grep 'Ended' 'makrec.log1' | tail -2")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2001 12:16 PM
тАО10-08-2001 12:16 PM
Re: script help
You already posted this question before. Check this thread out.
http://forums.itrc.hp.com/cm/QuestionAnswer/1,11866,0x21eac6af36b7d5118ff10090279cd0f9,00.html
The solution works. I tried it out.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-17-2001 09:56 AM
тАО10-17-2001 09:56 AM
Re: script help
#!/usr/bin/ksh
##################################################################
# Declare variables
PATH=/usr/bin:/usr/local/bin
SERVERS="/opt/data/all-servers"
PAGE="/opt/apache/htdocs/backups/test.html"
TMP_PAGE1="/tmp/list1.html"
TMP_PAGE2="/tmp/list2.html"
DATE=$(date)
COLOR=""
FAIL_CODE=""
END=""
# Make sure we start clean
/usr/bin/rm -f $TMP_PAGE1 $TMP_PAGE2
# Start the page
cat <<-EOF > $PAGE
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
Last updated: $DATE
NOTES:
TEST
TEST
TEST
EOF
# Start the table
cat <<-EOF >> $PAGE
EOF # Get the data for i in `cat $SERVERS` xxxxx xxxxxx do # Get the start time ssh $i "grep 'Started' /var/opt/ignite/logs/makrec.log1 2> /dev/null | tail -1" > $TMP_PAGE2 echo " " >> $TMP_PAGE2 echo $END >> $TMP_PAGE2 # Get the end time - will also use later for COLOR selection END=$(ssh $i "grep 'Completed' /var/opt/ignite/logs/makrec.log1 2> /dev/null | tail -1") echo " " >> $TMP_PAGE2 echo " | " >> $TMP_PAGE2 # Get the failure code and set the color FAIL_CODE=$(ssh $i "grep 'Ended' /var/opt/ignite/logs/makrec.log1 2> /dev/null | tail -1") if [ $FAIL_CODE -eq 0 ] then COLOR=RED else COLOR=GREEN fi # Also set the COLOR based on $END [ $(echo $END | grep -c Ended) -eq 1 ] && COLOR="GREEN" # Build the first column - This is where we set the color echo " | ||
" > $TMP_PAGE1 echo "" >> $TMP_PAGE1 echo "$i | " >> $TMP_PAGE1 echo "" >> $TMP_PAGE1 echo " " >> $TMP_PAGE1 # Pull it together cat $TMP_PAGE1 $TMP_PAGE2 >> $PAGE done # end the table echo " |
echo "" >> $PAGE