Here's a crazy idea: put each little block of code in its own file. So, create a file with this content:

#!/bin/sh /usr/bin/su - patrol /usr/adm/best1_default/bgs/scripts/best1collect - +q >> $1 2>&1

and name it 'start-bgs' in some directory. Then do the same for all other other case blocks and name them similarly. Then your script just becomes:

#!/bin/sh ... # set $agent to the agent you want to start cmdpath=$cmd_dir/start-$agent if ! -x $cmdpath; then echo Error - start script $cmdpath not found exit 1 fi $cmdpath $LOG # pass any relevant parameters here

Then when you need to add/change/delete agents you are just replacing files instead of trying to edit a few lines in a file. This should make things a lot easier to manage, especially if you have several hundred files to update.

It's a crazy idea!


In reply to Re: if elsif elsif prints all three. by pc88mxer
in thread if elsif elsif prints all three. by wcj75019

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.