6 Replies Latest reply on Aug 11, 2010 10:46 AM by Vinnie Lima

    Translating awk/sed into Windows cmd?

    Vinnie Lima

      This one is for the windows folks in here


      Have an E.O. working perfect for UNIX targets:


      /opt/OV/bin/opctemplate | awk 'NR > 4' | sed -e s/\"//g -e s/OVO\ settings/OVO_settings/g | awk '{ print $2"\t"$1"\t"$3"\t"$4 }'


      Basically it trims the first 4 lines of the text, and then translates some characters, then prints specific values out of the output. Need to do the same in Windows, but obviously no sed or awk available.  Not an option to install gawk or other windows-ported utilities. What can I do to have the same results but using native windows command line parsing utilities?


      The following command works and outputs data in windows 2008 server:


      nexec ??TARGET.HOST?? /C/"Program Files/HP/HP BTO Software"/bin/win64/opctemplate.bat


      *    List    installed    policies    for    host    'localhost'.
      Type    Name    Status    Version           
      configsettings    "OPC_OPCMON_OVERRIDE_THRESHOLD"    enabled    0100.0000           
      configsettings    "OPC_PERL_INCLUDE_INSTR_DIR"    enabled    0100.0000           
      configsettings    "OVO settings"    enabled    1           
      monitor    "SI-CPUBottleneckDiagnosis"    enabled    0100.0004           
      monitor    "SI-DiskCapacityMonitor"    enabled    0100.0020           
      monitor    "SI-GlobalCPUUtilization-AT"    enabled    0099.0005           
      monitor    "SI-MemoryBottleneckDiagnosis"    enabled    0100.0019           
      monitor    "SI-MemoryUtilization-AT"    enabled    0100.0009           
      monitor    "SI-SwapCapacityMonitor"    enabled    0100.1004           
      monitor    "SI-SwapUtilization-AT"    enabled    0100.0008           
      msgi    "InfraSPI-Messages"    enabled    0100.0001           
      msgi    "opcmsg(1|3)"    enabled    0009.0014           
      svcdisc    "SI-SystemDiscovery"    enabled    0100.0000      



      The intended output is to be as follows:


      OPC_PERL_INCLUDE_INSTR_DIR    CONFIGSETTINGS    enabled    0100.0000
      OVO_settings    CONFIGSETTINGS    enabled    1
      ThresholdOverridesLinux    CONFIGSETTINGS    enabled    0100.0000
      SI-LinuxBootLog    LOGFILE    enabled    0100.0003
      SI-LinuxKernelLog    LOGFILE    disabled    0100.0004
      SI-CPUBottleneckDiagnosis    MONITOR    enabled    0100.0004
      SI-DiskCapacityMonitor    MONITOR    enabled    0100.0020
      SI-GlobalCPUUtilization-AT    MONITOR    enabled    0099.0005
      SI-LinuxSshdProcessMonitor    MONITOR    enabled    0100.0003
      SI-LinuxXinetdProcessMonitor    MONITOR    enabled    0100.0003
      SI-MemoryBottleneckDiagnosis    MONITOR    enabled    0100.0019
      SI-MemoryUtilization-AT    MONITOR    enabled    0100.0009
      SI-RHELSyslogProcessMonitor    MONITOR    enabled    0100.0002
      SI-SwapCapacityMonitor    MONITOR    enabled    0100.1005
      SI-SwapUtilization-AT    MONITOR    enabled    0100.0008
      InfraSPI-Messages    OPCMSG    enabled    0100.0001
      opcmsg(1|3)    OPCMSG    enabled    0009.0014
      SI-SystemDiscovery    SVCDISC    enabled    0100.0000



      Thanks for any help.


        • 1. Re: Translating awk/sed into Windows cmd?
          Paul Seager-Smith

          Why not do an nexec to run /opt/OV/bin/opctemplate and redirect the output to a file and then just use the NSH awk and sed commands to process this file? It will save a you a lot of time trying to re-write the scripts for Windows.





          1 of 1 people found this helpful
          • 2. Re: Translating awk/sed into Windows cmd?
            Vinnie Lima

            I am Ok in doing what you suggested as long as I can do it all in one E.O. execution.


            Having to run a job to dump it to a file separately, so that another E.O. can parse the file is an option I rather not introduce if I don't have to.


            Any suggestion?



            • 3. Re: Translating awk/sed into Windows cmd?
              Wenchi Liao

              You can do it in one EO execution with a central execution NSH script. The script uses nexec to run the windows part, and sed/awk/whatever will be available on the app server to do the post-processing.

              1 of 1 people found this helpful
              • 4. Re: Translating awk/sed into Windows cmd?
                Vinnie Lima

                Is there a way to do this in E.O?  The command below works fine if I do an NSH prompt to the target server:


                emda-nbp-uea21% nexec emoa-nbp-uea03  /C/"Program Files/HP/HP BTO Software"/bin/win64/opctemplate.bat > cat //emoa-nbp-uea03/C/temp/file.txt ; cat //emoa-nbp-uea03/C/temp/file.txt | awk 'NR > 4' | sed -e s/\"//g -e s/OVO\ settings/OVO_settings/g | awk '{ print $2"\t"$1"\t"$3"
                \t"$4 }'

                OPC_OPCMON_OVERRIDE_THRESHOLD   configsettings  enabled 0100.0000
                OPC_PERL_INCLUDE_INSTR_DIR      configsettings  enabled 0100.0000
                OVO_settings    configsettings  enabled 1
                SI-CPUBottleneckDiagnosis       monitor enabled 0100.0004
                SI-DiskCapacityMonitor  monitor enabled 0100.0020
                SI-GlobalCPUUtilization-AT      monitor enabled 0099.0005
                SI-MemoryBottleneckDiagnosis    monitor enabled 0100.0019
                SI-MemoryUtilization-AT monitor enabled 0100.0009
                SI-SwapCapacityMonitor  monitor enabled 0100.1004
                SI-SwapUtilization-AT   monitor enabled 0100.0008
                InfraSPI-Messages       msgi    enabled 0100.0001
                opcmsg(1|3)     msgi    enabled 0009.0014
                SI-SystemDiscovery      svcdisc enabled 0100.0000



                But doesn't work in E.O. under central execution:


                nexec ??TARGET.HOST?? /C/"Program Files/HP/HP BTO Software"/bin/win64/opctemplate.bat > //??TARGET.HOST??/C/temp/file.txt ; cat //??TARGET.HOST??/C/temp/file.txt | awk 'NR > 4' | sed -e s/\"//g -e s/OVO\ settings/OVO_settings/g | awk '{ print $2"\t"$1"\t"$3"\t"$4 }'


                As it doesnt seem to be run as NSH.


                I'd like to do it within the E.O. configuration versus having to create an NSH script. Yes, may be asking too much


                Thanks for the help.

                • 5. Re: Translating awk/sed into Windows cmd?

                  Throw that in an NSH Script. That is your best bet, and would follow the practices Bill and I follow.

                  • 6. Re: Translating awk/sed into Windows cmd?
                    Vinnie Lima

                    Okey dokey - nsh script it is