<?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: script output in a nice pattern in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868120#M97724</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Well, you could use the printf function in 'awk', works pretty good for the quick and dirty formatting, just like the printf in C.  &lt;BR /&gt;&lt;BR /&gt;But if you are getting that far with your scripting I would suggest moving to Perl.  It can handle all kinds of formatting as well as running the commands for you, grabbing the output, parsing the fields, and printing a nice report and/or emailing it to you in most any format.  I've done something similar with the 'omnidb' command in OmniBack here and I have a Perl script that lists all the media used for the last 24 hours to ship offsite.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
    <pubDate>Thu, 19 Dec 2002 20:16:20 GMT</pubDate>
    <dc:creator>John Poff</dc:creator>
    <dc:date>2002-12-19T20:16:20Z</dc:date>
    <item>
      <title>script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868119#M97723</link>
      <description>Hi admins,&lt;BR /&gt;&lt;BR /&gt;I have a script that checks my backup status, tapes used and the drives.i have defined four variables&lt;BR /&gt;SI=`omnidb -sess -datalist "$datalist" | tail -1 |awk '{print $1}'`&lt;BR /&gt;AU=`omnirpt -report session_media  -sess $SI | grep A | awk '{print $1}'`&lt;BR /&gt;STAT=`omnidb -rpt  $SI -detail | grep Status | awk '{print $3}'`&lt;BR /&gt;TDU=`omnidb -sess $SI -detail | grep Device | awk '{print $4}' | sort -u`&lt;BR /&gt;&lt;BR /&gt;now i want tp output them in a good coloums or in a html fashion and email it to me.&lt;BR /&gt;curently i do a &lt;BR /&gt;echo $datalist $SI $AU $STAT $TDU &amp;gt;&amp;gt; /filename&lt;BR /&gt;and mail the file to my email. This comes kind of jumbled up&lt;BR /&gt;&lt;BR /&gt;any help will be appreciated...&lt;BR /&gt;thanks in advance&lt;BR /&gt;George</description>
      <pubDate>Thu, 19 Dec 2002 20:10:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868119#M97723</guid>
      <dc:creator>George Abraham_1</dc:creator>
      <dc:date>2002-12-19T20:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868120#M97724</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Well, you could use the printf function in 'awk', works pretty good for the quick and dirty formatting, just like the printf in C.  &lt;BR /&gt;&lt;BR /&gt;But if you are getting that far with your scripting I would suggest moving to Perl.  It can handle all kinds of formatting as well as running the commands for you, grabbing the output, parsing the fields, and printing a nice report and/or emailing it to you in most any format.  I've done something similar with the 'omnidb' command in OmniBack here and I have a Perl script that lists all the media used for the last 24 hours to ship offsite.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Dec 2002 20:16:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868120#M97724</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-12-19T20:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868121#M97725</link>
      <description>Hi George,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;use printf instead of echo.&lt;BR /&gt;&lt;BR /&gt;Look at printf's man page for more details on formwatting. The man page contains some good exapmles also.&lt;BR /&gt;&lt;BR /&gt;-Sri</description>
      <pubDate>Thu, 19 Dec 2002 20:16:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868121#M97725</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-12-19T20:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868122#M97726</link>
      <description>Hi George:&lt;BR /&gt;&lt;BR /&gt;Instead of 'echo', format your output with 'printf'.  You can easily columnize your data this way.  See the man pages for more information.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 19 Dec 2002 20:19:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868122#M97726</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-12-19T20:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868123#M97727</link>
      <description>&lt;BR /&gt;Hi&lt;BR /&gt;&lt;BR /&gt;can you tell me the syntax... Just want to print the 4 variables in a column manner...&lt;BR /&gt;&lt;BR /&gt;printf $datalist $SI $AU $STAT $ADU ?&lt;BR /&gt;&lt;BR /&gt;cheers&lt;BR /&gt;George</description>
      <pubDate>Thu, 19 Dec 2002 20:31:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868123#M97727</guid>
      <dc:creator>George Abraham_1</dc:creator>
      <dc:date>2002-12-19T20:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868124#M97728</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;You'll have to specify the format of each field.  For strings you use '%#s', where # is the size of the field.  For decimal integers, use '%#d', and for floating point numbers try '%#.#f'.&lt;BR /&gt;&lt;BR /&gt;I don't know what format your variables are, but if the first one is numeric and the next three are strings you could do something like this:&lt;BR /&gt;&lt;BR /&gt;printf "%8d  %10s  %15s  %8s \n" $SI $AU $STAT $TDU&lt;BR /&gt;&lt;BR /&gt;The '\n' will give you a new line character.&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Dec 2002 20:41:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868124#M97728</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-12-19T20:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868125#M97729</link>
      <description>Hi,&lt;BR /&gt;Of course printf can be used but this kind of formatting can be done with echo too. Just add some tabs.&lt;BR /&gt;&lt;BR /&gt;echo $datalist"\t"$SI"\t"$AU"\t"$STAT"\t"$TDU</description>
      <pubDate>Thu, 19 Dec 2002 20:42:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868125#M97729</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2002-12-19T20:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868126#M97730</link>
      <description>Hi George,&lt;BR /&gt;&lt;BR /&gt;A fairly simple approach:&lt;BR /&gt;&lt;BR /&gt;printf "%s | %s | %s | %s | %s" $datalist $SI $AU $STAT $TDU&lt;BR /&gt;&lt;BR /&gt;which would produce output that looks something like:&lt;BR /&gt;&lt;BR /&gt;first | second | third | fourth | fifth&lt;BR /&gt;&lt;BR /&gt;In perl:&lt;BR /&gt;&lt;BR /&gt;perl -wle "print join(' | ',@ARGV)" $datalist $SI $AU $STAT $TDU&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Vincent&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Dec 2002 20:46:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868126#M97730</guid>
      <dc:creator>Vincent Stedema</dc:creator>
      <dc:date>2002-12-19T20:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868127#M97731</link>
      <description>&lt;BR /&gt;hi&lt;BR /&gt;&lt;BR /&gt;I used the tab "\t" saperator and my output looks like this&lt;BR /&gt;&lt;BR /&gt;AUTOSYS_archive 2002/12/18-115  [AU6929]        Completed       DLT_3_commctl_off&lt;BR /&gt;AUTOSYS_online  2002/12/18-114  [AU6929] [AU6944]       Completed       DLT_3_commctl_off DLT_4_commctl_off&lt;BR /&gt;OS_NT_adevweb_offsite   2002/12/19-26   [AV1009] [AV1206]       Completed/Failures      DLT_1b_commctl_off DLT_2b_commctl_off&lt;BR /&gt;OS_NT_asybprod_offsite  2002/12/19-17   [AV1127] [AV1206]       Completed       DLT_1b_commctl_off DLT_2b_commctl_off&lt;BR /&gt;OS_NT_asybtest_offsite  2002/12/19-16   [AV1127] [AV1009]       Completed       DLT_3b_commctl_off DLT_4b_commctl_off&lt;BR /&gt;OS_NT_atrwweb1_offsite  2002/12/19-14   [AV1206] [AV1009]       Completed       DLT_1b_commctl_off DLT_2b_commctl_off&lt;BR /&gt;OS_NT_atrwweb2_offsite  2002/12/19-15   [AV1195] [AV1127]       Completed       DLT_3b_commctl_off DLT_4b_commctl_off&lt;BR /&gt;OS_NT_fmcache_offsite   2002/12/19-3    [AV1195]        Completed       DLT_2b_commctl_off&lt;BR /&gt;OS_NT_fmgenio_offsite   2002/12/19-4    [AV1206] [AV1127]       Completed       DLT_3b_commctl_off DLT_4b_commctl_off&lt;BR /&gt;OS_NT_fmprodapp1_offsite        2002/12/19-5    [AV1206] [AV1195]       Completed       DLT_1b_commctl_off DLT_2b_commctl_off&lt;BR /&gt;&lt;BR /&gt;any ideas to bring this to proper coloumns are welcome&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;George</description>
      <pubDate>Thu, 19 Dec 2002 21:01:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868127#M97731</guid>
      <dc:creator>George Abraham_1</dc:creator>
      <dc:date>2002-12-19T21:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868128#M97732</link>
      <description>Hi,&lt;BR /&gt;Sorry, there is to big differences in string lenght to use simple tabs. You have to use the printf command and set a suitable column with for each column:&lt;BR /&gt;&lt;BR /&gt;printf "%30s %20s %20s %15s %s" % $datalist $SI $AU $STAT $TDU &lt;BR /&gt;&lt;BR /&gt;You perhaps need to try wit different column with until you get a nice output.</description>
      <pubDate>Thu, 19 Dec 2002 21:30:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868128#M97732</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2002-12-19T21:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868129#M97733</link>
      <description>hi&lt;BR /&gt;&lt;BR /&gt;Thanks a lot... Any ideas on how to get this to html do as to email in a good looking fashion&lt;BR /&gt;&lt;BR /&gt;regards&lt;BR /&gt;George</description>
      <pubDate>Thu, 19 Dec 2002 22:30:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868129#M97733</guid>
      <dc:creator>George Abraham_1</dc:creator>
      <dc:date>2002-12-19T22:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868130#M97734</link>
      <description>Hi George,&lt;BR /&gt;&lt;BR /&gt;See if this simple script can help you. Once the "your_file" is created, run the following script to convert it into html. You need to filling  the maximum number of fields (MAXWORDS) your output file will have and the&lt;BR /&gt;output file name (SOURCE)and the output file name (HTML). Once you run the script, you will get a html file as you wanted. If it is not helpful, you can use the logic though. &lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh                                                        &lt;BR /&gt;MAXWORDS=9                                                            &lt;BR /&gt;HTML=source.html                                                      &lt;BR /&gt;SOURCE=source                                                         &lt;BR /&gt;                                                                      &lt;BR /&gt;cat &amp;lt;&amp;lt; EOF &amp;gt; $HTML                                                    &lt;BR /&gt;                                                                &lt;BR /&gt;                                                                &lt;BR /&gt;&lt;TABLE border="2"&gt;                                                      &lt;BR /&gt;&lt;TBODY&gt;&lt;TR&gt;                                                                  &lt;BR /&gt;&lt;TD align="center" colspan="$MAXWORDS"&gt;&lt;B&gt;Report&lt;/B&gt;&lt;/TD&gt; &lt;/TR&gt;           &lt;BR /&gt;&lt;TR&gt;                                                                  &lt;BR /&gt;EOF                                                                   &lt;BR /&gt;                                                                      &lt;BR /&gt;cat $SOURCE |while read LINE                                          &lt;BR /&gt;do                                                                    &lt;BR /&gt;                                                                      &lt;BR /&gt;WORDS=0                                                               &lt;BR /&gt;   for ENTRY in $LINE                                                 &lt;BR /&gt;   do                                                                 &lt;BR /&gt;echo "&lt;TD&gt;$ENTRY&lt;/TD&gt;" &amp;gt;&amp;gt; $HTML                                       &lt;BR /&gt;    (( WORDS = $WORDS + 1 ))                                          &lt;BR /&gt;       done                                                           &lt;BR /&gt;  if [ $WORDS -lt $MAXWORDS ]              &lt;BR /&gt;     then                                  &lt;BR /&gt;    while [ $WORDS -le $MAXWORDS ]         &lt;BR /&gt;           do                              &lt;BR /&gt;          echo "&lt;TD&gt;&lt;/TD&gt;" &amp;gt;&amp;gt; $HTML        &lt;BR /&gt;    (( WORDS = $WORDS + 1 ))               &lt;BR /&gt;                 done                      &lt;BR /&gt;                    fi                     &lt;BR /&gt;               echo "&lt;/TR&gt;" &amp;gt;&amp;gt; $HTML       &lt;BR /&gt;       done                                &lt;BR /&gt;                                           &lt;BR /&gt;  cat &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; $HTML                      &lt;BR /&gt;  &lt;/TBODY&gt;&lt;/TABLE&gt;                                 &lt;BR /&gt;                                    &lt;BR /&gt;                                    &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Dec 2002 23:52:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868130#M97734</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-12-19T23:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868131#M97735</link>
      <description>At the risk of being overly simplistic: I write all my reports as comma-delimited, and email them to myself with a .csv extension.  That way, I can open them with a spreadsheet and edit, print or massage the data to my heart's content:&lt;BR /&gt;&lt;BR /&gt;echo "$datalist,$SI,$AU,$STAT,$TDU" &amp;gt;&amp;gt; /filename &lt;BR /&gt;uuencode filename filename|mailx -s "Data" myemailaddy@whereIam.com&lt;BR /&gt;&lt;BR /&gt;This attaches the document to the email.  From my email box, I just double click the attachment, and it opens up in Excel.  This lets me do the formatting and pretty printing without too much shell scripting.  Shell scripting is fun, but I'm lazy....&lt;BR /&gt;&lt;BR /&gt;Good Luck&lt;BR /&gt;Chris</description>
      <pubDate>Fri, 20 Dec 2002 16:43:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868131#M97735</guid>
      <dc:creator>Chris Vail</dc:creator>
      <dc:date>2002-12-20T16:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868132#M97736</link>
      <description>Hi John,&lt;BR /&gt;&lt;BR /&gt;can you post the perl script you told about.. i will appreciate that&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;George</description>
      <pubDate>Mon, 23 Dec 2002 17:24:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868132#M97736</guid>
      <dc:creator>George Abraham_1</dc:creator>
      <dc:date>2002-12-23T17:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: script output in a nice pattern</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868133#M97737</link>
      <description>Hi George,&lt;BR /&gt;&lt;BR /&gt;Here is my Perl script.  I posted it as an attachment so that the formatting won't get too hosed up.&lt;BR /&gt;&lt;BR /&gt;The name of the script is used_media.pl.  Let me give you a little background on our environment.  We use OmniBack and we have two main tape pools.  The first pool is for all our non-essential machines [test, development, etc.] and the second pool is for all our critical machines that we would need to recover in case of a disaster.  The second pool has the string '-DR' at the end of the pool name, and that is the pool that this script looks for.  We use a large LTO tape library, and each day we eject all the tapes used in the -DR pool overnight and send them offsite for three weeks.  When we eject the tapes we move them to a pool named Offsite, so that OmniBack doesn't try to use them when they aren't around.  Also, we have numbered containers which we have setup as Locations in OmniBack, so when we move tapes to the Offsite pool we also change the location to be the container number, which makes it a little easier to track down and audit tapes.&lt;BR /&gt;&lt;BR /&gt;If you run the script without any options it will give you a report of all the tapes used in the -DR pool for the last 24 hours.  Using the -m option will move the tapes listed in the report to the Offsite pool, and using the -c option with a container number changes the location field for each tape.  If you specify the -e option the tapes will be ejected to the CAP.  We added logic to count the number of tapes being ejected so that the script will pause and wait for input if you have more tapes that can be ejected in the CAP at one time [in this version of the script it is 14 tapes].&lt;BR /&gt;&lt;BR /&gt;This script might do more than you are looking for, but feel free to take it, use it, change it, etc.  The report uses the 'format' function in Perl which is a really great way to format a report.  If you don't need all the fancy options you can just strip those parts out and use the report.&lt;BR /&gt;&lt;BR /&gt;Have fun!&lt;BR /&gt;&lt;BR /&gt;JP&lt;BR /&gt;</description>
      <pubDate>Mon, 23 Dec 2002 22:09:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-output-in-a-nice-pattern/m-p/2868133#M97737</guid>
      <dc:creator>John Poff</dc:creator>
      <dc:date>2002-12-23T22:09:23Z</dc:date>
    </item>
  </channel>
</rss>

