0
votes

I have on my enviroment Arcserve Backup solution for tape backup, and I, inside it we have a program called ca_qmgr that can return the status of the current backup jobs, I used a vbs script to return the following information:

snapshot

On this image we have the field "LAST-RESULT" that shows me the status of the jobs like "Finished, failed, cancelled, etc". Bellow I have the VBS script that I'm using:

Dim ObjExec
Dim strFromProc

Set objShell = WScript.CreateObject("WScript.Shell")
Set ObjExec = objShell.Exec("""C:\Program Files (x86)\CA\ARCserve Backup\ca_qmgr.exe"" -list")
strFromProc = ObjExec.StdOut.ReadAll()
WScript.Echo  strFromProc

With this I can get the output of the jobs current status, now I need to parse the text of the output and, everytime a job is with status "FAILED" return value "1" to me, and when whatever other status is shown return value "0" to me, anyone have any ideas?

Here is the copied output :

JOB# JOBID    STATUS            EXEC-TIME      JOB-TYPE   LAST-RESULT         OWNER       EXECUTIONHOST DESCRIPTION
----------------------------------------------------------------------------------------------------------
     2     0      HOLD  07/09/2019 11:00:00      ROTATION   UNAVAILABLE      No Owner           ICBHOST03 Tarefa de proteΒo do banco de dados
     4    67     READY  08/02/2019 06:00:00        BACKUP      FINISHEDICB\administrador           ICBHOST03 Backup Diario
     3    80     READY  08/02/2019 09:00:00        BACKUP        FAILED        caroot           ICBHOST03 Backup Mensal
     1    79     READY  08/02/2019 12:00:00    DB-PRUNING      FINISHED      No Owner           ICBHOST03 Tarefa de remoΒo de banco de dados
     5    58     READY  08/05/2019 09:00:00        BACKUP      FINISHED        caroot           ICBHOST03 Backup Segunda
1
I couldn't attach the image to the question, so I posted it on imgur here : imgur.com/OZ2Rfwz - origamaster
I edited the question and embedded the image; however, since it just shows text it would be better if you'd copy it and place it directly in the question, so potential answerers could copy it and experiment with it... - aschipfl
From the picture it's obvious that the column headers are right justified (except the last one). You could use that to split into fields. Or use a RegEx to change two or more spaces into a delimiter (again Description has only one space in between). - user6811411
Hello LotPings, could you explain to me how would I do that ? I'm new to vbscript - origamaster
To address a person precede the name with a @, otherwise there is no notification. JOB# 4 seems to break the formatting so you might be better off simply searching for the text FAILED with the function instr(0,strFromProc,"FAILED",1). - user6811411

1 Answers

1
votes

With your guys help I managed to do it like this :

Dim ObjExec
Dim strFromProc

Set objShell = WScript.CreateObject("WScript.Shell")
Set ObjExec = objShell.Exec("""C:\Program Files (x86)\CA\ARCserve Backup\ca_qmgr.exe"" -list")
strFromProc = ObjExec.StdOut.ReadAll()
result = InStr(strFromProc, "FAILED")
if isEmpty(result) then 
    WScript.Echo "1"

else 
    WScript.Echo "0"
End if

So when (result) catches the position of the "FAILED" status it will end on the "if" clause and if the value is empty then it will return me value 1 so I can see that all jobs are not with failed status, and return me value 0 when it finds the "FAILED" status and result is not empty, thanks for the help.