<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: In need of a script - in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823930#M270643</link>
    <description>Note:&lt;BR /&gt;&lt;BR /&gt;syslogd is running&lt;BR /&gt;$ ps -ef|grep syslogd&lt;BR /&gt;    root   156     1  0   Feb 06 ?       62:43 /usr/sbin/syslogd&lt;BR /&gt; kv13588  5122  4897  0 15:39:06 pts/1    0:00 grep syslogd&lt;BR /&gt;&lt;BR /&gt;This is the location and file name of the file where the syslos messages are going to&lt;BR /&gt;$ ls /var/log/rtrlog&lt;BR /&gt;/var/log/rtrlog&lt;BR /&gt;$ &lt;BR /&gt;</description>
    <pubDate>Fri, 14 Jul 2006 17:40:37 GMT</pubDate>
    <dc:creator>Rob Johnson_3</dc:creator>
    <dc:date>2006-07-14T17:40:37Z</dc:date>
    <item>
      <title>In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823914#M270627</link>
      <description>I have a number of CiscoWorks Campus Mgr servers that can send Syslog messages to 1 of 3 Syslog servers.  I’m trying to find a way to grep through the /var/log/rtrlog file every hour and email any messages from this file that have :%CISCOWORKS-CampusManager and LINK_TRUNK in the message.  Getting something to run every hour is the easy part (just cron it).  Having it email me the output is easy as well.&lt;BR /&gt;&lt;BR /&gt;I’m thinking the hard part is going to be not emailing messages that were emailed the previous hour.&lt;BR /&gt;&lt;BR /&gt;Can someone help me put a script together that can do this?  Oh yea, my scripting skills are very, very weak.&lt;BR /&gt;&lt;BR /&gt;$ grep -i campus rtrlog|grep -i link_trunk      &lt;BR /&gt;Jul 13 02:43:13 nmsccm05.kp.org 3124:2006 Jul 13 5:43:13 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcamosc1.oak.ca.kp.org,GigabitEthernet5/48],[10.236.45.4,6/24]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3683:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc133.str.ca.kp.org,GigabitEthernet0/1],[lcastrc1.str.ca.kp.org,3/4]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3685:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc121.str.ca.kp.org,GigabitEthernet0/1],[lcastrc1.str.ca.kp.org,3/3]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3687:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc118.str.ca.kp.org,GigabitEthernet0/2],[lcastrc2.str.ca.kp.org,3/2]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3688:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc151.str.ca.kp.org,GigabitEthernet0/1],[lcastrc1.str.ca.kp.org,3/5]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3690:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc154.str.ca.kp.org,GigabitEthernet0/2],[lcastrc2.str.ca.kp.org,3/5]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3692:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc139.str.ca.kp.org,GigabitEthernet0/2],[lcastrc2.str.ca.kp.org,3/7]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3693:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc124.str.ca.kp.org,GigabitEthernet0/2],[lcastrc2.str.ca.kp.org,3/3]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3694:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc1.str.ca.kp.org,3/8],[lcastrc143.str.ca.kp.org,GigabitEthernet0/1]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3695:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc116.str.ca.kp.org,GigabitEthernet0/1],[lcastrc1.str.ca.kp.org,3/2]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3696:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc135.str.ca.kp.org,GigabitEthernet0/2],[lcastrc2.str.ca.kp.org,3/4]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3700:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc138.str.ca.kp.org,GigabitEthernet0/1],[lcastrc1.str.ca.kp.org,3/7]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3701:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc2.str.ca.kp.org,3/8],[lcastrc142.str.ca.kp.org,GigabitEthernet0/2]&lt;BR /&gt;$ &lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 12:29:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823914#M270627</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2006-07-14T12:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823915#M270628</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;The simplest way, IMHO, is to copy log file onto another file after each cron running, i.e.&lt;BR /&gt;&lt;BR /&gt;LOGF=var/log/rtrlog &lt;BR /&gt;BACKLOG=var/log/rtrlog.bck&lt;BR /&gt;MAILF=/tmp/$$&lt;BR /&gt;grep -e ":%CISCOWORKS-CampusManager -e LINK_TRUNK  $LOGF &amp;gt; $MAILF&lt;BR /&gt;if [ -s $MAILF ]; then&lt;BR /&gt;cat $MAILF | mailx -s subject your@address&lt;BR /&gt;fi&lt;BR /&gt;cat $LOGF &amp;gt;&amp;gt; $BACKLOG&lt;BR /&gt;&amp;gt;$LOGF&lt;BR /&gt;&lt;BR /&gt;By this way you begin with empty file after each the script running&lt;BR /&gt;&lt;BR /&gt;HTH</description>
      <pubDate>Fri, 14 Jul 2006 13:09:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823915#M270628</guid>
      <dc:creator>Victor Fridyev</dc:creator>
      <dc:date>2006-07-14T13:09:13Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823916#M270629</link>
      <description>Another approach that doesn't involve copying the logs: &lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;my_mon=`date +%b`&lt;BR /&gt;my_day=`date +%d`&lt;BR /&gt;my_hr=`date +%H`&lt;BR /&gt;&lt;BR /&gt;if [ $my_day -lt 10 ]&lt;BR /&gt;  then&lt;BR /&gt;    my_date="$my_mon  $my_day $my_hr"&lt;BR /&gt;  else&lt;BR /&gt;    my_date="$my_mon $my_day $my_hr"&lt;BR /&gt;fi&lt;BR /&gt;grep ^"${my_date}" rtrlog|grep -i cisco|grep -i link_trunk&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;inelegant, perhaps, but quick and easy to understand. &lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 14:26:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823916#M270629</guid>
      <dc:creator>Mark Fenton</dc:creator>
      <dc:date>2006-07-14T14:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823917#M270630</link>
      <description>the pair my_date lines don't look quite right in proportional font -- there should be an extra space where the day of the month is less than 10. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 14:46:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823917#M270630</guid>
      <dc:creator>Mark Fenton</dc:creator>
      <dc:date>2006-07-14T14:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823918#M270631</link>
      <description>You guys are both awesome!!  &lt;BR /&gt;&lt;BR /&gt;I'm not able to get to either of the 3- servers at the moment but will let you know which route I choose to use and if I have any problems.&lt;BR /&gt;&lt;BR /&gt;Again, Thanks so much!!!!!!!!!!!!!!!!!!!!!!!!!!</description>
      <pubDate>Fri, 14 Jul 2006 14:50:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823918#M270631</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2006-07-14T14:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823919#M270632</link>
      <description>I'm not sure I understand what your saying when you say &lt;BR /&gt;&lt;BR /&gt;"the pair my_date lines don't look quite right"&lt;BR /&gt;&lt;BR /&gt;Can you elaborate?&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 14:59:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823919#M270632</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2006-07-14T14:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823920#M270633</link>
      <description>in the first line with my_date=...&lt;BR /&gt;there should be two spaces between ${my_mon} and ${my_day}, whereas in the second there should only be one. &lt;BR /&gt;&lt;BR /&gt;I guess the posting algorhythm on this site removes "extra" spaces in some lines of text. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 15:22:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823920#M270633</guid>
      <dc:creator>Mark Fenton</dc:creator>
      <dc:date>2006-07-14T15:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823921#M270634</link>
      <description>Gotcha...&lt;BR /&gt;&lt;BR /&gt;Thank you!!&lt;BR /&gt;&lt;BR /&gt;'Not sure I quiet understand it but, like I said, I'm not programmed to be a programmer!&lt;BR /&gt;&lt;BR /&gt;I'll be able to try this out later this afternoon or 1st thing tomorrow.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 15:30:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823921#M270634</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2006-07-14T15:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823922#M270635</link>
      <description>&lt;!--!*#--&gt;I have a better idea and it doesn't involve copying files. Let's create a "watchfile" that consists of one 1 having 2 data values: SYSLOG_PID LAST_LINE&lt;BR /&gt;&lt;BR /&gt;If that file is not found or if the PID of the current executing syslogd daemon doesn't match the stored value then we start the syslog.log scan at line 1 otherwise we start at LAST_LINE + 1.&lt;BR /&gt;&lt;BR /&gt;At the end of our scan, we rewrite the "watchfile" and we are ready for the next invocation.&lt;BR /&gt;---------------------------------------&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;typeset TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset INFILE="/var/adm/syslog/syslog.log"&lt;BR /&gt;typeset WATCHFILE=${TDIR}/Syswatch.dat &lt;BR /&gt;typeset A1=${TDIR}/X${$}_1.awk&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;trap 'eval rm -f ${A1}' 0 1 2 3 15&lt;BR /&gt;&lt;BR /&gt;get_syslogd_pid()&lt;BR /&gt;{&lt;BR /&gt;  typeset -i PSTAT=0&lt;BR /&gt;  typeset -i SPID=$(UNIX95= ps -Csyslogd -o pid=)&lt;BR /&gt;  PSTAT=${?}&lt;BR /&gt;  echo "${SPID}"&lt;BR /&gt;  return ${PSTAT}&lt;BR /&gt;} # get_syslogd_pid&lt;BR /&gt;&lt;BR /&gt;# if syslogd's PID does not match the stored value&lt;BR /&gt;# or the watchfile is not found or syslogd is not running&lt;BR /&gt;# then read syslog from beginning else start at stored line + 1&lt;BR /&gt;&lt;BR /&gt;cat &amp;lt;&amp;lt; !EOF! &amp;gt; ${A1}&lt;BR /&gt;{&lt;BR /&gt;  while (NR &amp;lt; begin_line) next;&lt;BR /&gt;  if (\$0 ~ "%CISCOWORKS-CampusManager.+LINK_TRUNK")&lt;BR /&gt;    {&lt;BR /&gt;      printf("%s\n",\$0)&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;END {&lt;BR /&gt;  printf("%d %d\n",pid,NR) &amp;gt; wfile&lt;BR /&gt;}&lt;BR /&gt;!EOF!&lt;BR /&gt;&lt;BR /&gt;typeset -i BEGIN_LINE=1&lt;BR /&gt;&lt;BR /&gt;typeset -i OLDPID=-1&lt;BR /&gt;typeset -i OLD_LINE=0 &lt;BR /&gt;&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;typeset -i CURRPID=$(get_syslogd_pid)&lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ ${STAT} -eq 0 &amp;amp;&amp;amp; ${CURRPID} -gt 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    if [[ -r "${WATCHFILE}" &amp;amp;&amp;amp; -s "${WATCHFILE}" ]]&lt;BR /&gt;      then&lt;BR /&gt;        read OLDPID OLD_LINE &amp;lt; "${WATCHFILE}"&lt;BR /&gt;        if [[ ${OLDPID} -eq ${CURRPID} ]]&lt;BR /&gt;          then&lt;BR /&gt;            BEGIN_LINE=$((${OLD_LINE} + 1))&lt;BR /&gt;          fi&lt;BR /&gt;      fi  &lt;BR /&gt;  fi&lt;BR /&gt;&lt;BR /&gt;awk -v begin_line=${BEGIN_LINE} \&lt;BR /&gt; -v pid=${CURRPID} -v "wfile=${WATCHFILE}" -f "${A1}" "${INFILE}"&lt;BR /&gt;STAT=${?}&lt;BR /&gt;exit ${STAT}   &lt;BR /&gt;------------------------------------------&lt;BR /&gt;  &lt;BR /&gt;All you have to do is capture the stdout of this script and send it to mail and you are done.</description>
      <pubDate>Fri, 14 Jul 2006 15:50:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823922#M270635</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-14T15:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823923#M270636</link>
      <description>I wasn't able to follow what A. Clay Stephenson is talking about.  If I have to, I will try his method.  &lt;BR /&gt;&lt;BR /&gt;I tried the other method and looks like something is wrong.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;*******************************************&lt;BR /&gt;$ cat syslogwatch.sh                   &lt;BR /&gt;#!/bin/sh&lt;BR /&gt;set -x&lt;BR /&gt;my_mon=`date +%b`&lt;BR /&gt;my_day=`date +%d`&lt;BR /&gt;my_hr=`date +%H`&lt;BR /&gt; &lt;BR /&gt;if [ $my_day -lt 10 ]&lt;BR /&gt;then&lt;BR /&gt;my_date="$my_mon  $my_day $my_hr"&lt;BR /&gt;else&lt;BR /&gt;my_date="$my_mon $my_day $my_hr"&lt;BR /&gt;fi&lt;BR /&gt;grep "${my_date}" /var/log/rtrlog|grep -i campus&lt;BR /&gt;$ &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Here's the output with set -x&lt;BR /&gt;$./syslogwatch.sh                     &lt;BR /&gt;+ date +%b &lt;BR /&gt;my_mon=Jul&lt;BR /&gt;+ date +%d &lt;BR /&gt;my_day=14&lt;BR /&gt;+ date +%H &lt;BR /&gt;my_hr=14&lt;BR /&gt;+ [ 14 -lt 10 ] &lt;BR /&gt;my_date=Jul 14 14&lt;BR /&gt;+ + grepgrep Jul 14 14 /var/log/rtrlog &lt;BR /&gt; -i campus &lt;BR /&gt;$ &lt;BR /&gt;&lt;BR /&gt;I know there is something in the file because...&lt;BR /&gt;&lt;BR /&gt;$ grep -i campus /var/log/rtrlog       &lt;BR /&gt;Jul 12 03:37:48 nmsccm06.kp.org 26:2006 Jul 12 6:37:48 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_MULTI:[10.246.222.50,GigabitEthernet0/2], [lcamanc2.ca.kp.org,8/13]&lt;BR /&gt;Jul 12 03:37:48 nmsccm06.kp.org 37:2006 Jul 12 6:37:48 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_MULTI:[lcamanc1.ca.kp.org,9/6], [lcamanc38-ter.ca.kp.org,GigabitEthernet0/1]&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 16:22:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823923#M270636</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2006-07-14T16:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823924#M270637</link>
      <description>It's rather simple, we create a little file that stores two pieces of data. The pid of syslogd and the line number where we finished our scan last time. We then run ps and determine the PID of the currently running syslogd. It's possible that someone has stopped syslogd, copied syslog to syslog.old, and restarted syslogd. This is typically done nitely. We want to detect that condition and if a new syslogd is running then we need to start reading from the beginning. If the same syslogd is still running as when we last executed the script then we should start at the next new line.&lt;BR /&gt;Most of the work is done by calling awk and the last thing awk does is rewrite the little file.&lt;BR /&gt;&lt;BR /&gt;The nice feature of this approach is if no new matching lines are found, nothing is output to stdout.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 16:32:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823924#M270637</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-14T16:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823925#M270638</link>
      <description>OK. I created a file called syslogwatch2.sh and put the contents of your post in it. &lt;BR /&gt;&lt;BR /&gt;I made it executable.  What else do I need to do?  &lt;BR /&gt;&lt;BR /&gt;Do I also need to create another file?  If so, do I need to give it a certain name?</description>
      <pubDate>Fri, 14 Jul 2006 16:46:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823925#M270638</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2006-07-14T16:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823926#M270639</link>
      <description>Here's what happens when I try to run this one.  &lt;BR /&gt;&lt;BR /&gt;$ chmod +x syslogwatch2.sh&lt;BR /&gt;$ ./syslogwatch2.sh       &lt;BR /&gt;./syslogwatch2.sh: typeset: not found&lt;BR /&gt;./syslogwatch2.sh: typeset: not found&lt;BR /&gt;./syslogwatch2.sh: typeset: not found&lt;BR /&gt;./syslogwatch2.sh: typeset: not found&lt;BR /&gt;./syslogwatch2.sh: syntax error at line 14: `(' unexpected&lt;BR /&gt;$ &lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 16:48:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823926#M270639</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2006-07-14T16:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823927#M270640</link>
      <description>&lt;!--!*#--&gt;It's rather simple, all you need now is a wrapper script that you call from cron. We need to do a little extra work because cron's PATH is very sparse.&lt;BR /&gt;&lt;BR /&gt;--------------------------------&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;typeset TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset T1=${TDIR}/X${$}_1.txt&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;typeset WHO="mickey@mouse.com donald@duck.com"&lt;BR /&gt;&lt;BR /&gt;export PATH=${PATH}:/usr/bin:/usr/local/bin&lt;BR /&gt;# should include your directory containing &lt;BR /&gt;# the watchsyslog2.sh&lt;BR /&gt;&lt;BR /&gt;# automatically remove temp file upon exit&lt;BR /&gt;# or receipt of a signal e.g. Ctrl-C&lt;BR /&gt;#&lt;BR /&gt;trap 'eval rm -f ${T1} 0 1 2 3 15'&lt;BR /&gt;&lt;BR /&gt;watchdog2.sh &amp;gt; ${T1}&lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ -s "${T1}" ]] # any output?&lt;BR /&gt;  then&lt;BR /&gt;    mailx -s "Network stuff" "${WHO}" &amp;lt; ${T1}&lt;BR /&gt;    STAT=${?}&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;------------------------------------------&lt;BR /&gt;&lt;BR /&gt;That should do it. The first time you run it you should get tons of mail; the next time only the new lines. &lt;BR /&gt;&lt;BR /&gt;You do not need to create the /var/tmp/Syswatch.dat file because if not found, it assumes this is the first run. It will always rewite the file whether or not it existed before.&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 17:05:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823927#M270640</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-14T17:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823928#M270641</link>
      <description>Well, I thought surely there must be a typo in all of that stuff since I simply copy-and-pasted from a similar script but when I copied-and-pasted from my posting back to a UNIX box, it ran perfectly.&lt;BR /&gt;&lt;BR /&gt;I did see one logical error in the wrapper script:&lt;BR /&gt;watchdog2.sh &amp;gt; ${T1}&lt;BR /&gt;should be&lt;BR /&gt;watchsyslog2.sh &amp;gt; ${T1} # or whatever you name the inner script.&lt;BR /&gt;&lt;BR /&gt;If you copied and pasted and are getting a typeset not found error then something in "The Force" tells me you are not running the POSIX shell.</description>
      <pubDate>Fri, 14 Jul 2006 17:17:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823928#M270641</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-14T17:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823929#M270642</link>
      <description>Wow, I'm having a difficult time following you!!&lt;BR /&gt;&lt;BR /&gt;It looks like I'm running the ksh:&lt;BR /&gt;&lt;BR /&gt;$ echo $SHELL&lt;BR /&gt;/usr/bin/ksh&lt;BR /&gt;$ &lt;BR /&gt;&lt;BR /&gt;I have 2 scripts, the 1st is sylogwatch2.sh. the wrapper is called syslogwrapper.sh.  Take a look.  I'm sure there are a number of things wrong.  Please advise.&lt;BR /&gt;&lt;BR /&gt;$ pwd&lt;BR /&gt;/export/home/kv13588/scripts&lt;BR /&gt;$ ls&lt;BR /&gt;syslogwatch2.sh   syslogwrapper.sh&lt;BR /&gt;$ cat syslogwatch2.sh&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt; &lt;BR /&gt;typeset TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset INFILE="/var/adm/syslog/syslog.log"&lt;BR /&gt;typeset WATCHFILE=${TDIR}/Syswatch.dat &lt;BR /&gt;typeset A1=${TDIR}/X${$}_1.awk&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;trap 'eval rm -f ${A1}' 0 1 2 3 15&lt;BR /&gt; &lt;BR /&gt;get_syslogd_pid()&lt;BR /&gt;{&lt;BR /&gt;  typeset -i PSTAT=0&lt;BR /&gt;  typeset -i SPID=$(UNIX95= ps -Csyslogd -o pid=)&lt;BR /&gt;  PSTAT=${?}&lt;BR /&gt;  echo "${SPID}"&lt;BR /&gt;  return ${PSTAT}&lt;BR /&gt;} # get_syslogd_pid&lt;BR /&gt; &lt;BR /&gt;# if syslogd's PID does not match the stored value&lt;BR /&gt;# or the watchfile is not found or syslogd is not running&lt;BR /&gt;# then read syslog from beginning else start at stored line + 1&lt;BR /&gt; &lt;BR /&gt;cat &amp;lt;&amp;lt; !EOF! &amp;gt; ${A1}&lt;BR /&gt;{&lt;BR /&gt;  while (NR &amp;lt; begin_line) next;&lt;BR /&gt;  if (\$0 ~ "%CISCOWORKS-CampusManager.+LINK_TRUNK")&lt;BR /&gt;    {&lt;BR /&gt;      printf("%s\n",\$0)&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;END {&lt;BR /&gt;  printf("%d %d\n",pid,NR) &amp;gt; wfile&lt;BR /&gt;}&lt;BR /&gt;!EOF!&lt;BR /&gt; &lt;BR /&gt;typeset -i BEGIN_LINE=1&lt;BR /&gt; &lt;BR /&gt;typeset -i OLDPID=-1&lt;BR /&gt;typeset -i OLD_LINE=0 &lt;BR /&gt; &lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;typeset -i CURRPID=$(get_syslogd_pid)&lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ ${STAT} -eq 0 &amp;amp;&amp;amp; ${CURRPID} -gt 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    if [[ -r "${WATCHFILE}" &amp;amp;&amp;amp; -s "${WATCHFILE}" ]]&lt;BR /&gt;      then&lt;BR /&gt;        read OLDPID OLD_LINE &amp;lt; "${WATCHFILE}"&lt;BR /&gt;        if [[ ${OLDPID} -eq ${CURRPID} ]]&lt;BR /&gt;          then&lt;BR /&gt;            BEGIN_LINE=$((${OLD_LINE} + 1))&lt;BR /&gt;          fi&lt;BR /&gt;      fi  &lt;BR /&gt;  fi&lt;BR /&gt; &lt;BR /&gt;awk -v begin_line=${BEGIN_LINE} \&lt;BR /&gt;-v pid=${CURRPID} -v "wfile=${WATCHFILE}" -f "${A1}" "${INFILE}"&lt;BR /&gt;STAT=${?}&lt;BR /&gt;exit ${STAT}   &lt;BR /&gt; &lt;BR /&gt;$ cat syslogwrapper.sh&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;typeset TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset T1=${TDIR}/X${$}_1.txt&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;typeset WHO="rob.a.johnson@verizon.com"&lt;BR /&gt; &lt;BR /&gt;export PATH=${PATH}:/usr/bin:/usr/local/bin&lt;BR /&gt;# should include your directory containing &lt;BR /&gt;# the watchsyslog2.sh&lt;BR /&gt; &lt;BR /&gt;# automatically remove temp file upon exit&lt;BR /&gt;# or receipt of a signal e.g. Ctrl-C&lt;BR /&gt;#&lt;BR /&gt;trap 'eval rm -f ${T1} 0 1 2 3 15'&lt;BR /&gt; &lt;BR /&gt;watchdog2.sh &amp;gt; ${T1}&lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ -s "${T1}" ]] # any output?&lt;BR /&gt;  then&lt;BR /&gt;    mailx -s "Network stuff" "${WHO}" &amp;lt; ${T1}&lt;BR /&gt;    STAT=${?}&lt;BR /&gt;  fi&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;$ &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 17:23:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823929#M270642</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2006-07-14T17:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823930#M270643</link>
      <description>Note:&lt;BR /&gt;&lt;BR /&gt;syslogd is running&lt;BR /&gt;$ ps -ef|grep syslogd&lt;BR /&gt;    root   156     1  0   Feb 06 ?       62:43 /usr/sbin/syslogd&lt;BR /&gt; kv13588  5122  4897  0 15:39:06 pts/1    0:00 grep syslogd&lt;BR /&gt;&lt;BR /&gt;This is the location and file name of the file where the syslos messages are going to&lt;BR /&gt;$ ls /var/log/rtrlog&lt;BR /&gt;/var/log/rtrlog&lt;BR /&gt;$ &lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 17:40:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823930#M270643</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2006-07-14T17:40:37Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823931#M270644</link>
      <description>OK, I attached the inner script and modified it to use /var/log/rtrlog. As an attachment, it should be most difficult to inadvertently "improve".&lt;BR /&gt;&lt;BR /&gt;If you modify this script and you see any lines that end with "\" make absolutely certain that nothing (including spaces) follows the backslash. This is a continuation and may be part of your syntax problems. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;First rm /var/tmp/Syswatch.dat if it exists and then execute the attached script from the shell and see if you get any output.&lt;BR /&gt;It should create a new /var/tmp/Syswatch.dat file. Execute the script again and you should get no output.&lt;BR /&gt;At any time, you can rm the Syswatch.dat file and the script will forget all it knows about where it finished. Until you get the output of this script working then there is no need to go further. You should also check the Regular Expression matching in the awk script to see if you have any input that actually matches; that's this stuff (CISCOWORKS ...):&lt;BR /&gt;&lt;BR /&gt;cat &amp;lt;&amp;lt; !EOF! &amp;gt; ${A1}&lt;BR /&gt;{&lt;BR /&gt;  while (NR &amp;lt; begin_line) next;&lt;BR /&gt;  if (\$0 ~ "%CISCOWORKS-CampusManager.+LINK_TRUNK")&lt;BR /&gt;    {&lt;BR /&gt;      printf("%s\n",\$0)&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;END {&lt;BR /&gt;  printf("%d %d\n",pid,NR) &amp;gt; wfile&lt;BR /&gt;}&lt;BR /&gt;!EOF!&lt;BR /&gt;&lt;BR /&gt;When you finally get the inner script working then you can worry about the wrapper.&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 18:43:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823931#M270644</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-14T18:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823932#M270645</link>
      <description>By the way, I am making the silly assumption since you posted this in an HP-UX forum that this is actually running on an HP-UX box. If not, and (shebang) #!/usr/bin/sh doesn't actually invoke the POSIX shell then that explains much of your difficulty. Moreover, if this happens to be a Solaris box then you should use nawk rather than awk. You should probably change the shebang line to invoke the Korn shell if this isn't HP-UX. &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jul 2006 19:14:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823932#M270645</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-07-14T19:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: In need of a script -</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823933#M270646</link>
      <description>It looks like the box I'm trying to run this on is Solaris.  I hope that's not causing the problem...&lt;BR /&gt;&lt;BR /&gt;$ pwd&lt;BR /&gt;/export/home/kv13588/scripts&lt;BR /&gt;$ ls&lt;BR /&gt;pswatch.sh        syslogwatch.sh    syslogwatch2.sh   syslogwrapper.sh&lt;BR /&gt;$ ls /var/tmp&lt;BR /&gt;112233-12.SUNWhea                113146-06.SUNWapchr&lt;BR /&gt;112963-18.SUNWtoo                116561-04.SUNWdmfex&lt;BR /&gt;112963-18.SUNWtoox               install_it_Sun_StorEdge_SAN.log&lt;BR /&gt;113073-14.SUNWcarx               restart_rsac.log&lt;BR /&gt;113073-14.SUNWcsr                rsac-audit.log&lt;BR /&gt;113146-06.SUNWapchd&lt;BR /&gt;$ ./syslogwatch2.sh&lt;BR /&gt;./syslogwatch2.sh: typeset: not found&lt;BR /&gt;./syslogwatch2.sh: typeset: not found&lt;BR /&gt;./syslogwatch2.sh: typeset: not found&lt;BR /&gt;./syslogwatch2.sh: typeset: not found&lt;BR /&gt;./syslogwatch2.sh: syntax error at line 14: `(' unexpected&lt;BR /&gt;$ ls /var/tmp      &lt;BR /&gt;112233-12.SUNWhea                113146-06.SUNWapchr&lt;BR /&gt;112963-18.SUNWtoo                116561-04.SUNWdmfex&lt;BR /&gt;112963-18.SUNWtoox               install_it_Sun_StorEdge_SAN.log&lt;BR /&gt;113073-14.SUNWcarx               restart_rsac.log&lt;BR /&gt;113073-14.SUNWcsr                rsac-audit.log&lt;BR /&gt;113146-06.SUNWapchd&lt;BR /&gt;$ grep %CISCOWORKS-CampusManager /var/log/rtrlog|grep LINK_TRUNK&lt;BR /&gt;Jul 13 02:43:13 nmsccm05.kp.org 3124:2006 Jul 13 5:43:13 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcamosc1.oak.ca.kp.org,GigabitEthernet5/48],[10.236.45.4,6/24]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3683:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc133.str.ca.kp.org,GigabitEthernet0/1],[lcastrc1.str.ca.kp.org,3/4]&lt;BR /&gt;Jul 14 03:43:50 nmsccm06.kp.org 3685:2006 Jul 14 6:43:50 EDT:%CISCOWORKS-CampusManager-5-DCRP_LINK_TRUNK:[lcastrc121.str.ca.kp.org,GigabitEthernet0/1],[lcastrc1.str.ca.kp.org,3/3]&lt;BR /&gt;&lt;BR /&gt;$ uname -a&lt;BR /&gt;SunOS wdcrtrlog1 5.9 Generic_118558-02 sun4u sparc SUNW,Sun-Fire-V240&lt;BR /&gt;$</description>
      <pubDate>Fri, 14 Jul 2006 19:22:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/in-need-of-a-script/m-p/3823933#M270646</guid>
      <dc:creator>Rob Johnson_3</dc:creator>
      <dc:date>2006-07-14T19:22:55Z</dc:date>
    </item>
  </channel>
</rss>

