Batch Scripting output format in table format -
i have created batch script below, , using balt utility send output on email.
set length=0 /f "tokens=1 delims=/" %%t in ("%date%") set tt=%%t /f "tokens=2 delims=/" %%a in ("%date%") set da=%%a /f "tokens=3 delims=/" %%b in ("%date%") set db=%%b /f "tokens=4 delims=/" %%c in ("%date%") set dc=%%c /f "tokens=1 delims=: " %%i in ('time /t') set dd=%%i /f "tokens=2 delims=: " %%j in ('time /t') set de=%%j /f "tokens=3 delims=: " %%k in ('time /t') set df=%%k c: cd \siebserver\siebsrvr\bin srvrmgr /g mt-wi-sblgatew:2320 /e siebelpro /u sadmin /p sadm1npw /i "c:\ujj\comm.cfg" ren status.csv status_old.csv findstr /v /r /c:["srvrmgr"]["list"] status_old.csv > status.csv copy status.csv "c:\ujj\status.txt del status.csv exit
but output looks below:
sv_name cc_alias cp_num_run_tasks cp_max_tasks cp_actv_mts_procs cp_max_mts_procs cp_disp_run_state --------- ------------------------- ---------------- ------------ ----------------- ---------------- ----------------- sblprod01 ecommunicationsobjmgr_enu 11 100 4 4 running sblprod02 ecommunicationsobjmgr_enu 9 100 4 4 running sblprod04 ecommunicationsobjmgr_enu 8 100 4 4 running sblprod03 ecommunicationsobjmgr_enu 16 100 4 4 running 4 rows returned. sv_name cc_alias cp_num_run_tasks cp_max_tasks cp_actv_mts_procs cp_max_mts_procs cp_disp_run_state --------- ------------- ---------------- ------------ ----------------- ---------------- ----------------- sblprod02 eaiobjmgr_enu 75 200 8 8 running sblprod03 eaiobjmgr_enu 71 200 8 8 running sblprod01 eaiobjmgr_enu 90 200 8 8 running sblprod04 eaiobjmgr_enu 73 200 8 8 running 4 rows returned. srvrmgr> spool off spool off
how can make output in table format.
if want actual .csv
file commas instead of tabs , spaces code should work. more realiable way of obtaining date information added well.
@echo off setlocal enabledelayedexpansion set length=0 :: obtaining date information /f "tokens=2 delims==+-" %%i in ('wmic os localdatetime /value ^| findstr "="') ( set _date=%%i set yyyy=!_date:~0,4! set mm=!_date:~4,2! set dd=!_date:~6,2! set hh=!_date:~8,2! set min=!_date:~10,2! set sec=!_date:~12,2! set mili=!_date:~-6! ) cd \siebserver\siebsrvr\bin srvrmgr /g mt-wi-sblgatew:2320 /e siebelpro /u sadmin /p sadm1npw /i "c:\ujj\comm.cfg" ren status.csv status_old.csv findstr /v /r /c:["srvrmgr"]["list"] status_old.csv > status.csv ::replacing tabs , spaces commas obtain actual .csv file set "output=" if exist status_mod.csv del status_mod.csv /f "tokens=* delims=" %%i in ('findstr "_" status.csv') ( %%j in (%%i) ( set "output=!output!%%j," ) echo !output:~0,-1! >> status_mod.csv set "output=" ) copy /y status_mod.csv "c:\ujj\status.txt" del status_mod.csv
Comments
Post a Comment