Announcement

Collapse
No announcement yet.

Need script help

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

  • Need script help

    I'm trying to write a .net script which will take the 2nd element from an array which has a dos command runs as input, then feed that element into another dos command and parse out the elements I'm looking for.

    Can any of you coders tell me what I'm doing wrong.
    It appears that Set is not supported... How can I get around this?

    Thanks in advance

    Robert

    Code:
    Sub Main()
    
     Dim MyNSRMM
     Dim MyTape
     Dim MyNSRINFO
     Dim MyCap
     Dim MyPer
    
    
      
     set WshShell = CreateObject("WScript.Shell")
    
    
     MyNSRMM = Split(WshShell.Run("C:\Progra~1\nsr\bin\nsrmm"))
     MyTape = MyNSRMM(2)
    
     
     MyNSRINFO = Split(WshShell.Run("C:\Progra~1\nsr\bin\mminfo.exe -a -r written,%used" & MyTape))
    
    
     MyCap = MyNSRINFO(3) + " " + MyNSRINFO(4)
     MyPer = MyNSRINFO(5)
      
      hs.WriteLog("Debug", MyCap, MyPer) 
     
     set WshShell = Nothing
    
    End Sub
    HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

  • #2
    First of all you need a prototype for your sub main like this:
    Sub Main(parm as object)

    Then you can simply drop the set keywork as it's not needed in a .vb script.
    -Rupp
    sigpic

    Comment


    • #3
      Thanks Rupp...

      Now I get

      Script compile error: Name 'WshShell' is not declared.on line 25


      It's getting late...

      Robert
      HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

      Comment


      • #4
        With .net scripts all variables must be dimed to something ie
        Dim WshShell as object
        -Rupp
        sigpic

        Comment


        • #5
          I think the biggest problem I have is running a prgram within a split function to get the desired data.

          Dim WshShell as object


          MyNSRMM = Split(WshShell.Run("C:\Progra~1\nsr\bin\nsrmm"))

          Can anyone tell me why this fails.

          Robert
          HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

          Comment


          • #6
            Originally posted by langenet View Post
            I think the biggest problem I have is running a prgram within a split function to get the desired data.

            Dim WshShell as object


            MyNSRMM = Split(WshShell.Run("C:\Progra~1\nsr\bin\nsrmm"))

            Can anyone tell me why this fails.

            Robert
            Look up the split function.

            http://visualbasic.about.com/od/lear.../blvbsplit.htm

            The string class has a split method. It takes a single string parameter (the delimiter) and returns a single dimension array of sub-strings.

            Dim a as string="abc.def.ghi"
            dim b() as string
            b=a.split(".")

            The above will yield:

            b(0)= "abc"
            b(1)= "def"
            b(2)= "ghi"



            What exactly are you trying to do?

            tenholde
            tenholde

            Comment


            • #7
              Thanks...
              I'm trying to run a dos program nsrmm and have it's results put into an array.

              .... man this is simple in ksh!

              I would like to get the 2nd element out of the array.
              HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

              Comment


              • #8
                When you run this DOS program, what does it do? Where is it placing the data that you are trying to retrieve?

                When you run the Shell command to have the DOS program executed, you at best may get back from the Shell command the return code from the DOS program -- I'm not even sure of that.

                The DOS program does what with its output? You have to have some way of getting the data from the DOS program.

                tenholde
                tenholde

                Comment


                • #9
                  Here is what the first command returns. I just want tapebck.000

                  c:\nsrmm
                  4mm 20GB tape tapebck.000 mounted on \\.\Tape0, write enabled
                  I'm figuring that putting the above into an array is the best way to get that element out.

                  It then is used as input on the second command.

                  c:\mminfo.exe -a -r written,%used tapebck.000"
                  written (%)
                  5322 MB 13%

                  Basically, I want 5322 MB 13% so that I can add these to my virtual device to see how much tape I have used and if I need to change prior to the next backup.

                  So besides ghosting monthly, and backing up some stuff to another drive daily, I am sure I am in a minority that still uses tape. (more so because of historical reasons)

                  Any help would be greatly appreciated.

                  Robert
                  HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

                  Comment


                  • #10
                    When you say the command returns "xxxx", do you mean that if you execute that command from a command prompt that "xxxx" is displayed on the console? If so, then you have to have the output written to a file instead of displayed upon the console. Then, you can read the file to return the output of the DOS command.

                    For example: if you enter "dir c:" you get a directory listing on the console. If you enter "dir c: > c:\temp\output.txt" then a file is created that contains the output.

                    Is this making any sense?



                    tenholde
                    tenholde

                    Comment


                    • #11
                      Yes... the result is displayed in the cmd window. Hum... I was under the impression that this would behave like a UNIX shell call. If I have to write a file, then parse through it... I suppose I could do that. I execute a batch script at backup time and so could just add this to it.


                      Edit... the more I think about it, the less it makes sense for a decent solution. Because I will first need to run nsrmm via call WshSell.run and direct to file1 and parse the tape name out. Then create another call with the input from above... direct output to a file2 again, then parse out what I need.
                      Isn't there any better way to do this???

                      Thanks for that!

                      Robert
                      Last edited by langenet; October 8th, 2009, 06:27 PM.
                      HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

                      Comment


                      • #12
                        How frequently would you want to update the device with this information. Is this a daily thing?

                        tenholde
                        tenholde

                        Comment


                        • #13
                          No... weekly. Just that the process seems inefficient. I thought that stdout within a cmd shell could be directed to a variable.

                          Is there a better way???

                          Thanks

                          Robert
                          HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

                          Comment


                          • #14
                            Can you do something like this?
                            sVar = WshShell.Run("C:\Progra~1\nsr\bin\nsrmm")
                            msgbox(sVar)
                            .
                            .
                            .
                            -Rupp
                            sigpic

                            Comment


                            • #15
                              Originally posted by Rupp View Post
                              Can you do something like this?
                              sVar = WshShell.Run("C:\Progra~1\nsr\bin\nsrmm")
                              msgbox(sVar)
                              .
                              .
                              .
                              I think sVar will just be the program's return code.

                              tenholde
                              tenholde

                              Comment

                              Working...
                              X