John Darby
asked on
Shell script syntax convert to VBScript
I have a script which does a great job of using the uptime.exe to output a barebones uptime number. I am wanting to use a VBScript to do the same task and have it acquire hostnames from "servers.txt". The text file has one servername per line.
Uptime.exe <servername> is the syntax for remote access.
I am inluding the existing shell script below.
@echo off
setlocal
for /f "tokens=6,7,8,10 delims=, " %%a in ('"uptime.exe"') do (
set dd=%%a%%b
set hh=%%c
set mm=%%d
)
if %hh% LSS 10 set hh=0%hh%
if %mm% LSS 10 set mm=0%mm%
set Uptime=%dd%,%hh%:%mm%
echo Uptime: %Uptime%
pause
Uptime.exe <servername> is the syntax for remote access.
I am inluding the existing shell script below.
@echo off
setlocal
for /f "tokens=6,7,8,10 delims=, " %%a in ('"uptime.exe"') do (
set dd=%%a%%b
set hh=%%c
set mm=%%d
)
if %hh% LSS 10 set hh=0%hh%
if %mm% LSS 10 set mm=0%mm%
set Uptime=%dd%,%hh%:%mm%
echo Uptime: %Uptime%
pause
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Vinny, you are a great instructor! I appreciate the time you took to explain the details. When I finally get a handle on scripting in VB, I plan to tackle C#. But until then, I am thankful for your splendid tutelage.
basicinstinct,
thanks for your input as well. Maybe I should give a more through explanation with my next question. I am definately the learner here and am seeking ways to identify and remember good syntax. Sometimes, porting from shell to VBS helps.
Thanks both!
JohnD
basicinstinct,
thanks for your input as well. Maybe I should give a more through explanation with my next question. I am definately the learner here and am seeking ways to identify and remember good syntax. Sometimes, porting from shell to VBS helps.
Thanks both!
JohnD
If it ain't broke, don't fix it.