UNSOLVED

MarcIngle

updated

20 years ago

M

MarcIngle

6 Posts

0

2053

December 22nd, 2006 09:00

Command line to set date & time on Clariion arrays...

I have seventeen Clariion arrays that periodically require their internal clocks to be sync-ed with the clock on our Navisphere Manager server. (Sure wish Clariions could be configured to use NTP protocol.) Anyway, I would like to do this using a script. Does anyone have a script that parses the date & time from a Windows server and then uses NaviCLI to set the time/date on the SPs of the arrays? Thanks in advance for your assistance!

=-Marc->
  • MarcIngle

    6 Posts

    1136

    0

    Posted December 28th, 2006 13:00

    Thank you for your reply, but unfortunately it doesn't answer my question. I know that NaviCLI can be used to set the time/date on an Clarrion array. I am looking for a script that parses the system time/date (i.e. the output from the 'time /t' and 'date /t' commands) and then sets the time/date on each storage processor. I do not know how to parse the system time/date within a batch file (command prompt) script, to make it fit the NaviCLI syntax, which is why I am asking for such a script (if anyone has one).

    Thanks!
  • 1136

    0

    Posted December 28th, 2006 13:00

    You can use navicli from an attached host. then you can script and cron it:

    # navicli setsptime -h
    usage: setsptime <-M Month> <-D Day> <-Y Year> <-h Hour> <-m Minute>

    see the man page for navicli for the full syntax.
  • EKellerman

    76 Posts

    1136

    1

    Posted December 29th, 2006 05:00

    Try this:

    For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set date=%%a-%%b-%%c)

    For /f "tokens=1-2 delims=: " %%a in ('time /t') do (set time=%%a-%%b)

    You can call the variables then like this:
    %date% %time%

    I'm not a programmer, but this is what we are going to use to automate Clariion analyzer archive retrieving.

    ...to avoid confusion I should have specified that this is Windows Batch scripting.

    Message was edited by:
    EKellerman
  • MarcIngle

    6 Posts

    1136

    0

    Posted December 29th, 2006 11:00

    Using the info in your reply I was able to figure out how to separate the individual components of the time /d and date /d commands. (This will be used in the NaviCLI setsptime command syntax.)

    set ztime=""
    set zhour=""
    set zminute=""
    set zdate=""
    set zmonth=""
    set zday=""
    set zyear=""
    set ztime=%time%
    set zdate=%date%

    for /F "tokens=2" %%a in ("%zdate%") do set zdate=%%a
    for /F "tokens=1-2 delims=:" %%a in ("%ztime%") do set zhour=%%a
    for /F "tokens=1-2 delims=:" %%a in ("%ztime%") do set zminute=%%b
    for /F "tokens=1-3 delims=/" %%a in ("%zdate%") do set zmonth=%%a
    for /F "tokens=1-3 delims=/" %%a in ("%zdate%") do set zday=%%b
    for /F "tokens=1-3 delims=/" %%a in ("%zdate%") do set zyear=%%c

    I have a text file with IP addresses in it. (One IP per line... a total of 34 lines.) Do you know how I can read each IP address from the text file so that it could be used in the following command? ... navicli -h xxx.xxx.xxx.xxx {<-- the IP address from the text file} setsptime -M %zmonth% -D %zday% -Y %zyear% -h %zhour% -m %zminute%

    Thanks for your assistance thus far!

    =-Marc->
  • Allen Ward

    6 Operator

    •

    2124 Posts

    1136

    1

    Posted January 2nd, 2007 07:00

    You can use the same FOR /F commands you have been using to read lines from a text file as well...

    FOR /F %i in (myfile.txt) do @ECHO %i

    This example will read "myfile.txt" and perform the command (@ECHO %i) for each line in the file. This example will give you output the same as using the TYPE command on the file.

    For your example just replace the "myfile.txt" with your filename and replace the @ECHO %i with your command line, using %i where you need to insert the IP address.

    Actually though, since you are calling an external program and are using so many variable, you may want to set up a subroutine in your batch file that gets called by this command. It will simplify reading (and future editing) of the entire script.
  • MarcIngle

    6 Posts

    1136

    0

    Posted January 2nd, 2007 11:00

    Thanks for the info! Using this info and info that I obtain from previous responses, I was able to build the following batch file to set time time/date on all of my Clariion arrays...

    @echo off
    setlocal

    rem !! Clear Local Variables

    set zTime=""
    set zHour=""
    set zMinute=""
    set zDate=""
    set zMonth=""
    set zDay=""
    set zYear=""

    echo *******************************************************************
    echo * Batch File to Set Storage Processor's Date and Time on Multiple *
    echo * Clariion Arrays Programmatically *
    echo * --------------------------------------------------------------- *
    echo * Note: The time and date used by this batch file is obtained *
    echo * from the clock of the machine that this batch file is executed *
    echo * on. Please make sure that the clock reflects the correct time *
    echo * and date before continuing! *
    echo * *
    echo * In addition, this batch file requires that the Clariion NaviCLI *
    echo * be installed on the machine from which it is executed. *
    echo * *
    echo * Hit 'Ctrl-C' at the "Press any key to continue..." prompt below *
    echo * to abort this batch file. *
    echo *******************************************************************
    echo.
    pause
    echo.
    echo Working...
    echo.

    for /F "eol=;" %%a in (Clariion_IPs.txt) do call:zSetSPTime %%a

    echo Finished!
    endlocal
    goto :zEnd

    :zSetSPTime

    rem !! Obtain an IP address from Clariion_IPs.txt file. Obtain current time and
    rem !! date. Note: The time and date change frequently; Consequently this batch
    rem !! file must obtain the current time and date each time through this loop to
    rem !! ensure that all arrays are programmed with the same time/date.

    rem !! The Clariion_IPs.txt file can be created using Windows Notepad. There
    rem !! should only be one IP address per line... i.e.
    rem !! 10.1.1.2
    rem !! 10.1.1.3
    rem !! .
    rem !! etc...

    set IPAddress=%1
    set zTime=%time%
    set zDate=%date%

    rem !! Parse the date and time variables for the components that are needed in
    rem !! the NaviCLI command.

    for /F "tokens=2" %%a in ("%zDate%") do set zDate=%%a
    for /F "tokens=1-2 delims=:" %%a in ("%zTime%") do set zHour=%%a
    for /F "tokens=1-2 delims=:" %%a in ("%zTime%") do set zMinute=%%b
    for /F "tokens=1-3 delims=/" %%a in ("%zDate%") do set zMonth=%%a
    for /F "tokens=1-3 delims=/" %%a in ("%zDate%") do set zDay=%%b
    for /F "tokens=1-3 delims=/" %%a in ("%zDate%") do set zYear=%%c

    rem !! Execute the NaviCLI Command to Set the SP's Time & Date

    echo navicli -h %IPAddress% setsptime -M %zMonth% -D %zDay% -Y %zYear% -h %zHour% -m %zMinute%
    navicli -h %IPAddress% setsptime -M %zMonth% -D %zDay% -Y %zYear% -h %zHour% -m %zMinute%

    :zEnd

    =-Marc->