Announcement

Collapse
No announcement yet.

I want to argue with Asher.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #46
    I really ought to learn bash scripting.

    Comment


    • #47
      Originally posted by Kuciwalker
      I really ought to learn bash scripting.
      That's another thing about shells. Helpful for automation.

      Eg, here's a script I combine with a cron job at work (cron job = triggered on a timer, in this case at 3am). It restarts a server process, and in the event of any problems automatically emails an onduty tech or pages someone if unavailable.

      Code:
      #! /bin/csh -f
      
      if ( $#argv != 1 ) then
          echo " "
          echo "WRONG NUMBER OF ARGUMENTS GIVEN : Please use the following syntax:"
            echo "earlyMorningProcessRestarter.csh (true or false)"
          echo "If the argument is true, the process checker will restart the server processes. "
          echo "If the argument is false, the processes will be checked, and support will be paged if down."
      else
      
          setenv restartBackend $1
          #st_checkprocesswrapper.csh > /tmp/LatestProcessCheck.results
          grep /bin/gss /tmp/LatestProcessCheck.results > /tmp/LatestGSSCheck.results
      
          if ( $restartBackend == 'true' ) then
      
              if (  `grep -c '* NOT RUNNING'  /tmp/LatestProcessCheck.results` == 0 )
      then
                  echo "Processes on `hostname` are all up and running.  No need to restart at `date`.";
      
              else if ( `grep -c '* NOT RUNNING'  /tmp/LatestProcessCheck.results` == 1 &&  `grep -c '* NOT RUNNING'  /tmp/LatestGSSCheck.results` == 1 ) then
                  echo " gss not running - but ok : No need to restart  at `date`."
      
              else
                  cat /tmp/LatestProcessCheck.results | mail (censored)
                  echo "Restarting on `hostname` at `date`" | mail (censored)
                  /home/lnstprod/utils/ldn_intradayrestart.csh lnstprod
      
              endif
      
          else if ( $restartBackend == 'false' ) then
      
              if (  `grep -c '* NOT RUNNING'  /tmp/LatestProcessCheck.results` == 0 ) then
                  echo "Processes on `hostname` are all up and running.  No need to page (censored) at `date`.";
      
              else if (  `grep -c '* NOT RUNNING'  /tmp/LatestProcessCheck.results` == 1 &&  `grep -c '* NOT RUNNING'   /tmp/LatestGSSCheck.results` == 1 ) then
                  echo " gss not running - but ok : No need to page (censored) at `date`."
      
              else
                  /opt/bin/bing eu-fit-middle-office "Server Processes not running on `hostname` please see email"
                  cat  /tmp/LatestProcessCheck.results | mail (censored)
              endif
      
          else
              echo " "
              echo "INVALID ARGUMENT GIVEN "
          endif
      endif
      "The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
      Ben Kenobi: "That means I'm doing something right. "

      Comment


      • #48
        Originally posted by Asher

        Here's an obvious one.

        Search and replace in text files...
        I think I already said this, but I don't use my computer for much more than word processing, web browsing, and game playing; so I'm going to throw something out here and see if it makes any sense.

        Could such a tool (or a similar tool) be used to... say... collectively modify the meta-data on all my music files so that they adhere to some uniform standard that works with how I want to organize them?
        Click here if you're having trouble sleeping.
        "We confess our little faults to persuade people that we have no large ones." - François de La Rochefoucauld

        Comment


        • #49
          Yes, provided you can find a tool to modify meta-data of music files.

          Such a thing is likely to contain logic, and is thus better implemented like a script I have above.

          An easier solution is to use an existing tool that already does that, eg Mp3tag
          "The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
          Ben Kenobi: "That means I'm doing something right. "

          Comment

          Working...
          X