5 Replies Latest reply: Jul 11, 2012 11:21 PM by Satapathy NameToUpdate RSS

Job must to fail if file count is less than eight

Alex Salyer

I have a OS job task type of command. We run this powershell script to count the number of files in a certain Business Objects folder. This command works and returns the number files in the folder. We  would like to add on to this comand and say if the files are less than or equal to eight to fail.

 

Hopefully somebody else has come across this.

  • 1. Job must to fail if file count is less than eight
    A. T.

    Hi Alex,

     

    Could provide some more details regarding the Job dependency or what do you want to achieve through these jobs?

    Moreover, i would like to know what do you want to do if :

    1. No. of files <= 8

    2. No. of files > 8

  • 2. Job must to fail if file count is less than eight
    Alex Salyer

    I am a newbie to IT and to control-m. I will try and explain it this best way I can. lol.

     

    We have a folder that has anywhere from 9 to 12 files that are dropped into it everyday. It is scheduled t in SQL scheduler it counts the number of files and if it counts less than 8 inside of the folder, it sends a email to the owner and fails.

     

    Basically we want to do the job in control-m to count the files in this particular folder. And if it counts eight files or less than eight files it needs to fail the job and send a notification to the owner. However if there are more than eight files in the folder the job just needs to end ok.

     

    1.No. of files <_8 job fails and sends notifcation. Red

    2. No. of files > 8 job ends ok. Green

  • 3. Job must to fail if file count is less than eight
    A. T.

    Hi Alex,

     

    To achieve what you want you can configure a VB Script in your job.

     

    Write a VB Script and Count the no. of files in the folder. If no. of files is less than 8 then quit script with return code 1. This will lead to Job end with Not Ok in Control-M. If Count is greater than 8 then quit script with return code 0. This will let the Control-M job end with OK.

     

    On ENDED Not Ok you can configure an email to be sent.

     

    Sample Script would be like:

     

    ---------------------------------

    Set fileobject = CreateObject("Scripting.FileSystemObject")

     

     

    Set DataFolder = fileobject.GetFolder("C:\Workspace\Test\CTM\")

    Set DataFiles = DataFolder.Files

    NumberOfFiles = DataFiles.Count

     

    if NumberOfFiles <=8  Then

     

              wscript.echo "Total No. of Files: " & NumberOfFiles

     

               wscript.echo "Not Ok"

     

              wscript.quit(1)

     

    else

     

              wscript.echo "Total No. of Files: " & NumberOfFiles

              wscript.echo "Ok"

     

     

              wscript.quit(0)

     

     

    End if

     

    ---------------------------

    Hope this helps.

  • 4. Job must to fail if file count is less than eight
    Alex Salyer

    Thanks I am going to try this and let you know how this works. Also I have no clue where to type this VB script into control-m Desktop. Can you kind of walk me through this. This my very first job ever. 

  • 5. Job must to fail if file count is less than eight
    Satapathy NameToUpdate

    HI Alex

     

    Copy the above code into a text file and save it with .vbs extension.

     

    Then create a job with type OS and in task type choose COMMAND.

     

    E.G

     

     

    In the command field give the script path following to CSRIPT command.

     

    I hope this will help you.