Forum Discussion

chack22's avatar
chack22
Level 4
12 years ago
Solved

nbpemreq -predict script

Not to keen on Windows scripting, so I'm hoping someone has done this before. Need to create a scheduled task that will email the output of nbpemreq -predict -date xx/xx/xx every day, but changing the date to 'todays' date each time it runs. Easy to do in solaris, but I can't find an easy way to do so in Windows. Any thoughts?
  • To get the date you need to use the variables - pick them from this string which will put the date, time and seconds in for you, all seperated by underscores

    You should be able to work out what is what from this so use the parts you want:

    %date:~-4,4%%date:~-7,2%%date:~0,2%_%time:~0,2%%time:~3,2%%time:~6,2%

    So the above gives 20131128_103247 (the last part is 10.32 and 47 seconds)

    As you need it in the format mm/dd/yyyy you will actually need to use:

    %date:~7,2%/%date:~0,2%/%date:~4,4% in your command when viweing but extra to pipe out - giving you:

    nbpemreq -predict -date %date:~-7,2%/%date:~0,2%/%date:~-4,4% >c:\predict_%date:~-4,4%%date:~-7,2%%date:~0,2%.txt

    This outputs to a predict_20131128.txt file (well it does today anyway!)

    You still need blat to then send the file to email but can just do that on a second line and then put both in a .bat file

    So final should be - if you put this in a predict.bat - this cleans up yesterdays file first

    del c:\predict*.txt

    nbpemreq -predict -date %date:~-7,2%/%date:~0,2%/%date:~-4,4% >c:\predict_%date:~-4,4%%date:~-7,2%%date:~0,2%.txt

    Blat c:\predict*.txt -s "nbpemreq predict" -t foo@bar.com

     

    Hope this helps

     

    #edit#

    if you dont have paths setup you need to add the path to nbpem req:

    "c:\program files\veritas\netbackup\bin\admincmd\nbpemreq" -predict ........

  • To get the date you need to use the variables - pick them from this string which will put the date, time and seconds in for you, all seperated by underscores

    You should be able to work out what is what from this so use the parts you want:

    %date:~-4,4%%date:~-7,2%%date:~0,2%_%time:~0,2%%time:~3,2%%time:~6,2%

    So the above gives 20131128_103247 (the last part is 10.32 and 47 seconds)

    As you need it in the format mm/dd/yyyy you will actually need to use:

    %date:~7,2%/%date:~0,2%/%date:~4,4% in your command when viweing but extra to pipe out - giving you:

    nbpemreq -predict -date %date:~-7,2%/%date:~0,2%/%date:~-4,4% >c:\predict_%date:~-4,4%%date:~-7,2%%date:~0,2%.txt

    This outputs to a predict_20131128.txt file (well it does today anyway!)

    You still need blat to then send the file to email but can just do that on a second line and then put both in a .bat file

    So final should be - if you put this in a predict.bat - this cleans up yesterdays file first

    del c:\predict*.txt

    nbpemreq -predict -date %date:~-7,2%/%date:~0,2%/%date:~-4,4% >c:\predict_%date:~-4,4%%date:~-7,2%%date:~0,2%.txt

    Blat c:\predict*.txt -s "nbpemreq predict" -t foo@bar.com

     

    Hope this helps

     

    #edit#

    if you dont have paths setup you need to add the path to nbpem req:

    "c:\program files\veritas\netbackup\bin\admincmd\nbpemreq" -predict ........

  • This was helpful and pointed me in the right direction. Thank you.