Re: Script to check local reboot by Ray
Ray
Wed Jan 21 10:40:41 CST 2004
If you want to pipe the uptime, just use:
uptime \\domain1>C:\test.txt
I'm changing the followup group to microsoft.public.win2000.cmdprompt.admin.
Ray at work
"IC" <anonymous@discussions.microsoft.com> wrote in message
news:13ea01c3dfa3$b9392860$a001280a@phx.gbl...
> Thank you. That work. I have to use /A in order to work.
>
> I was wondering if there is a way to pipe this to a file.
> Instead of rebooting the server, what about creating a
> file that indicate the uptime of those servers?
>
> At the Dos prompmt C:>reboot.bat > test.txt, the script
> will run and create a file called test.txt. When looking
> into test.txt, it will showed me the uptime of those
> servers. I tried writing a script and did not work.
>
>
> call :checkReboot \\domain1.company.com
> call :checkReboot \\domain2.company.com
> call :checkReboot \\domain3.company.com
> call :checkReboot \\domain4.company.com
> call :checkReboot \\domain5.company.com
> call :checkReboot \\domain6.company.com
>
> goto :EOF
>
> :checkReboot
> set server=%1
> for /f "tokens=8 delims= " %%q in ('uptime %server%') do
> (set /A numHours=%%q)
> IF %numHours% GTR 1 goto :EOF
>
>
>
> >-----Original Message-----
> >Your issue is in the line wrapping.
> >
> >Try this:
> >for /f "tokens=7 delims= " %%q in ('uptime %server%') do (
> > set /a numHours=%%q)
> >
> >There is an opening parenthese after "do" and then a
> carriage return. SET
> >/A numHours=%%q) is all on one line. How you had it
> before, it was:
> >
> >SET /A
> >numHours=%%q
> >
> >So, humHours was staring a new line.
> >
> >Ray at work
> >
> >
> >"IC" <anonymous@discussions.microsoft.com> wrote in
> message
> >news:123401c3df89$bbf0f430$a001280a@phx.gbl...
> >> There were 2 person who wrote this script and many
> thanks
> >> to them. I tried this script and I am receiving an
> error.
> >>
> >> call :checkReboot \\domain1.company.com
> >> call :checkReboot \\domain2.company.com
> >> call :checkReboot \\domain3.company.com
> >> call :checkReboot \\domain4.company.com
> >> call :checkReboot \\domain5.company.com
> >> call :checkReboot \\domain6.company.com
> >>
> >> goto :EOF
> >>
> >> :checkReboot
> >> set server=%1
> >> for /f "tokens=7 delims= " %%q in ('uptime %server%') do
> >> (set /a
> >> numHours=%%q)
> >> IF %numHours% GTR 1 (shutdown.exe
> server% /l /r /t:f /c /y)
> >>
> >>
> >> The syntax of the command is incorrect.
> >> 'numHours' is not recognized as an internal or external
> >> command,
> >> operable program or batch file.
> >> 1 was unexpected at this time.
> >>
> >>
> >> What is the correct syntax?
> >
> >
> >.
> >