<?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 shell script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923844#M817601</link>
    <description>I am writing a script to abort all omniback backup session that is still running.&lt;BR /&gt;&lt;BR /&gt;This is the output from the omnistat&lt;BR /&gt;&lt;BR /&gt;SessionID          Type            Status             User &lt;BR /&gt;===============================================================================&lt;BR /&gt;2003/03/11-18      Backup          Mount Request      root.sys@abc.net     &lt;BR /&gt;2003/03/11-20      Backup          In Progress        root.sys@abc.net&lt;BR /&gt;&lt;BR /&gt;This is my script.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;        OUTPUT=/tmp/abort_backup.rpt&lt;BR /&gt;        if [ -f $OUTPUT ]&lt;BR /&gt;        then&lt;BR /&gt;        rm $OUTPUT&lt;BR /&gt;        fi&lt;BR /&gt;        touch $OUTPUT&lt;BR /&gt;&lt;BR /&gt;CONDITION=$(/opt/omni/bin/omnistat | grep "No currently running sessions.")&lt;BR /&gt;if [ -n "$CONDITION" ]&lt;BR /&gt;then&lt;BR /&gt;        echo "Not Backup is running"&lt;BR /&gt;else&lt;BR /&gt;&lt;BR /&gt;PATTERN_TEXT="backup"&lt;BR /&gt;SESSION=`/opt/omni/bin/omnistat | grep -i "$PATTERN_TEXT" | awk '{print $1}'`&lt;BR /&gt;DATE=`date`&lt;BR /&gt;echo $SESSION &amp;gt; /tmp/abort_list&lt;BR /&gt;echo "$SESSION was aborted by script on $DATE"&lt;BR /&gt;#/opt/omni/bin/omniabort -ses $SESSION&lt;BR /&gt;rm /tmp/abort_list&lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;My problem is sometimes there might be more than 1 sessions running and I want to abort all of them.&lt;BR /&gt;&lt;BR /&gt;When I pipe the $SESSION to a file, all sessions number will be put into one line.&lt;BR /&gt;&lt;BR /&gt;For example in the abort_list file the session number will be look like this.&lt;BR /&gt;2003/1/1223-23 2003/2/1223-24&lt;BR /&gt;&lt;BR /&gt;But I would like to have a new line for 2003/2/1223-24 so that I can abort all the session one by one.</description>
    <pubDate>Tue, 11 Mar 2003 02:47:36 GMT</pubDate>
    <dc:creator>kholikt</dc:creator>
    <dc:date>2003-03-11T02:47:36Z</dc:date>
    <item>
      <title>shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923844#M817601</link>
      <description>I am writing a script to abort all omniback backup session that is still running.&lt;BR /&gt;&lt;BR /&gt;This is the output from the omnistat&lt;BR /&gt;&lt;BR /&gt;SessionID          Type            Status             User &lt;BR /&gt;===============================================================================&lt;BR /&gt;2003/03/11-18      Backup          Mount Request      root.sys@abc.net     &lt;BR /&gt;2003/03/11-20      Backup          In Progress        root.sys@abc.net&lt;BR /&gt;&lt;BR /&gt;This is my script.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;        OUTPUT=/tmp/abort_backup.rpt&lt;BR /&gt;        if [ -f $OUTPUT ]&lt;BR /&gt;        then&lt;BR /&gt;        rm $OUTPUT&lt;BR /&gt;        fi&lt;BR /&gt;        touch $OUTPUT&lt;BR /&gt;&lt;BR /&gt;CONDITION=$(/opt/omni/bin/omnistat | grep "No currently running sessions.")&lt;BR /&gt;if [ -n "$CONDITION" ]&lt;BR /&gt;then&lt;BR /&gt;        echo "Not Backup is running"&lt;BR /&gt;else&lt;BR /&gt;&lt;BR /&gt;PATTERN_TEXT="backup"&lt;BR /&gt;SESSION=`/opt/omni/bin/omnistat | grep -i "$PATTERN_TEXT" | awk '{print $1}'`&lt;BR /&gt;DATE=`date`&lt;BR /&gt;echo $SESSION &amp;gt; /tmp/abort_list&lt;BR /&gt;echo "$SESSION was aborted by script on $DATE"&lt;BR /&gt;#/opt/omni/bin/omniabort -ses $SESSION&lt;BR /&gt;rm /tmp/abort_list&lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;My problem is sometimes there might be more than 1 sessions running and I want to abort all of them.&lt;BR /&gt;&lt;BR /&gt;When I pipe the $SESSION to a file, all sessions number will be put into one line.&lt;BR /&gt;&lt;BR /&gt;For example in the abort_list file the session number will be look like this.&lt;BR /&gt;2003/1/1223-23 2003/2/1223-24&lt;BR /&gt;&lt;BR /&gt;But I would like to have a new line for 2003/2/1223-24 so that I can abort all the session one by one.</description>
      <pubDate>Tue, 11 Mar 2003 02:47:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923844#M817601</guid>
      <dc:creator>kholikt</dc:creator>
      <dc:date>2003-03-11T02:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923845#M817602</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You could do a 'for' loop on the contents of your $SESSION variable.  Something like this:&lt;BR /&gt;&lt;BR /&gt;PATTERN_TEXT="backup" &lt;BR /&gt;SESSION=`/opt/omni/bin/omnistat | grep -i "$PATTERN_TEXT" | awk '{print $1}'` &lt;BR /&gt;&lt;BR /&gt;for SESS in $SESSION;&lt;BR /&gt;do&lt;BR /&gt;DATE=`date` &lt;BR /&gt;echo $SESS &amp;gt; /tmp/abort_list &lt;BR /&gt;echo "$SESS was aborted by script on $DATE" &lt;BR /&gt;#/opt/omni/bin/omniabort -ses $SESS &lt;BR /&gt;rm /tmp/abort_list &lt;BR /&gt;fi &lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Mar 2003 03:04:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923845#M817602</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2003-03-11T03:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923846#M817603</link>
      <description>How about building this argument in to get your sessions, then using it to remove them.&lt;BR /&gt;&lt;BR /&gt;for i in `omnistat | sed -n '3,$p' | cut -c1-14`&lt;BR /&gt;do&lt;BR /&gt;omniabort -session $i&lt;BR /&gt;done</description>
      <pubDate>Tue, 11 Mar 2003 03:04:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923846#M817603</guid>
      <dc:creator>Michael Tully</dc:creator>
      <dc:date>2003-03-11T03:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923847#M817604</link>
      <description>Easiest way to two have two or three temporary work files  and one final output file.  Right now file1 has&lt;BR /&gt;&lt;BR /&gt;2003/1/1223-23 2003/1/1223-23 &lt;BR /&gt;&lt;BR /&gt;cat file1 | while read a&lt;BR /&gt;do&lt;BR /&gt;${echo $a | awk '{ print $2 }'&lt;BR /&gt;done &amp;gt; file2&lt;BR /&gt;&lt;BR /&gt;This will give you file1 with :&lt;BR /&gt;&lt;BR /&gt;2003/1/1223-23 &lt;BR /&gt;&lt;BR /&gt;...and file2 with&lt;BR /&gt;&lt;BR /&gt;2003/1/1223-23&lt;BR /&gt;&lt;BR /&gt;Now just append them both into file3&lt;BR /&gt;cat file1 &amp;gt; file3&lt;BR /&gt;cat file2 &amp;gt;&amp;gt; file3&lt;BR /&gt;&lt;BR /&gt;...for the following:&lt;BR /&gt;&lt;BR /&gt;2003/1/1223-23&lt;BR /&gt;2003/1/1223-23&lt;BR /&gt;</description>
      <pubDate>Tue, 11 Mar 2003 03:05:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923847#M817604</guid>
      <dc:creator>Michael Steele_2</dc:creator>
      <dc:date>2003-03-11T03:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: shell script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923848#M817605</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Just a few thoughts:&lt;BR /&gt;&lt;BR /&gt;You don't need to check a file's existence before removing it, just use the "rm -f filename" syntax to surpress any warning messages.&lt;BR /&gt;&lt;BR /&gt;Your OUTPUT file never seems to be used either.&lt;BR /&gt;&lt;BR /&gt;To save running omnistat more than once, you could wrap it in a loop and case construct:&lt;BR /&gt;&lt;BR /&gt;/opt/omni/bin/omnistat | while read line ; do&lt;BR /&gt;case $line&lt;BR /&gt;in&lt;BR /&gt;"No currently running sessions")&lt;BR /&gt; echo "Backup is not running"&lt;BR /&gt; ;;&lt;BR /&gt;*Backup*)&lt;BR /&gt; echo $line | awk '{print $1}' | read SESSION&lt;BR /&gt; /opt/omni/bin/omniabort -ses $SESSION&lt;BR /&gt; echo $SESSION was aborted by script on `date`&lt;BR /&gt; ;;&lt;BR /&gt;esac&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;rgds, Robin</description>
      <pubDate>Tue, 11 Mar 2003 08:52:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-help/m-p/2923848#M817605</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2003-03-11T08:52:11Z</dc:date>
    </item>
  </channel>
</rss>

