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!
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).
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%
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.
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
MarcIngle
6 Posts
1136
0
Posted December 28th, 2006 13:00
Thanks!