Page 1 of 1

Data manipulation and alignment

Posted: 16 Oct 2012 10:07
by Mahendra
This is WMQ command output handling....

we have a command to display the queue details

echo "display ql(*)" | runmqsc QMGR

output:-
_______


queue(system.jdfkjdhfkdj.khkdhfkd) type(LOCAL)
put(enabled) get(enabled)
Maxdepth(10000) curdepth(100)
usage(NORMAL)

queue(kjhfksjdfhdkfjhkdsfjds_2323.sdjj)
type(LOCAL) put(enabled)
get(disabled) Maxdepth(10000)
curdepth(100) usage(NORMAL)


i want to print the data
---------------------------------------------------------------------------
Queue | type |put | get |Maxdepth|cudepth|usage
----------------------------------------------------------------------------
system.jdfkjdhfkdj.khkdhfkd |local |enabled|enabled|10000 |100 |normal
kjhfksjdfhdkfjhkdsfjds_2323djj|local |enabled|disabled|10000 |100 |normal


(The maximum chars of the queue name is 48)




could you please help me some one to handle this situation.

Re: Data manipulation and alignment

Posted: 16 Oct 2012 10:10
by foxidrive
Please use the

Code: Select all

code
tags so we can see the format of the output properly. Your two examples have different output formats on the set of lines.

Re: Data manipulation and alignment

Posted: 16 Oct 2012 10:17
by Mahendra
if the length of the queue(any property) is more ...the next property will be displayed in the next line....subsequently rest of the properties also moved next line....only max of 2 properties displayed in a line(else 1). but all the properties displayed.

Re: Data manipulation and alignment

Posted: 16 Oct 2012 10:31
by Mahendra
Is there any way to concatenate the lines between queue and queue(below)...later with for loop we can manipulate

queue(system.jdfkjdhfkdj.khkdhfkd) type(LOCAL) put(enabled) get(enabled) Maxdepth(10000) curdepth(100) usage(NORMAL)

queue(kjhfksjdfhdkfjhkdsfjds_2323.sdjj) type(LOCAL) put(enabled) get(disabled) Maxdepth(10000) curdepth(100) usage(NORMAL)

Re: Data manipulation and alignment

Posted: 16 Oct 2012 11:18
by foxidrive
Mahendra wrote:Is there any way to concatenate the lines between queue and queue(below)...later with for loop we can manipulate

queue(system.jdfkjdhfkdj.khkdhfkd) type(LOCAL) put(enabled) get(enabled) Maxdepth(10000) curdepth(100) usage(NORMAL)

queue(kjhfksjdfhdkfjhkdsfjds_2323.sdjj) type(LOCAL) put(enabled) get(disabled) Maxdepth(10000) curdepth(100) usage(NORMAL)


This works to do that. file.txt is the input file, and out.txt is the final file.

Code: Select all

@echo off
for /f "delims=" %%a in (file.txt) do (
echo "%%a" | find /i "queue(" >nul && echo.>>out.txt
set /p "=%%a">>out.txt <nul
)

Re: Data manipulation and alignment

Posted: 17 Oct 2012 02:49
by Mahendra
Is there any way to print it without using any temp file ?

Re: Data manipulation and alignment

Posted: 17 Oct 2012 05:03
by foxidrive
MSDOS and batch files couldn't run without using temp files - Windows couldn't run without using temp files.


If you can't use temp files then state that from the start, not after you have a solution to your problem.

Re: Data manipulation and alignment

Posted: 17 Oct 2012 05:42
by Squashman
Mahendra wrote:Is there any way to print it without using any temp file ?

Every time you use Microsoft Word a temp file is created.

Re: Data manipulation and alignment

Posted: 17 Oct 2012 21:13
by Mahendra
echo "display ql(*)" | runmqsc QMGR

output:-
_______


queue(system.jdfkjdhfkdj.khkdhfkd) type(LOCAL)
put(enabled) get(enabled)
Maxdepth(10000) curdepth(100)
usage(NORMAL)

queue(kjhfksjdfhdkfjhkdsfjds_2323.sdjj)
type(LOCAL) put(enabled)
get(disabled) Maxdepth(10000)
curdepth(100) usage(NORMAL)

PS> all the properties are tab seperated. if the size of the any property is big, the property will be displayed in the next line(like as above).

i want to print the data
---------------------------------------------------------------------------
Queue | type |put | get |Maxdepth|cudepth|usage
----------------------------------------------------------------------------
system.jdfkjdhfkdj.khkdhfkd |local |enabled|enabled|10000 |100 |normal
kjhfksjdfhdkfjhkdsfjds_2323djj|local |enabled|disabled|10000 |100 |normal


(The maximum chars of the queue name is 48)

Re: Data manipulation and alignment

Posted: 27 Oct 2012 19:54
by Aacini

Code: Select all

@echo off
setlocal EnableDelayedExpansion
echo ---------------------------------------------------------------------------
echo Queue ^| type ^|put ^| get ^|Maxdepth^|cudepth^|usage
echo ----------------------------------------------------------------------------
set details=
echo "display ql(*)" | runmqsc QMGR > output.txt
for /F "delims=" %%a in (output.txt) do (
   set details=!details!%%a
   set property=%%a
   if "!property:usage=!" neq "!property!" (
      for /F "tokens=1-14 delims=()" %%a in ("!details!") do (
         echo %%b^|%%d^|%%f^|%%h^|%%j^|%%l^|%%n
      )
      set details=
   )
)

Output:

---------------------------------------------------------------------------
Queue | type |put | get |Maxdepth|cudepth|usage
----------------------------------------------------------------------------
system.jdfkjdhfkdj.khkdhfkd|LOCAL|enabled|enabled|10000|100|NORMAL
kjhfksjdfhdkfjhkdsfjds_2323.sdjj|LOCAL|enabled|disabled|10000|100|NORMAL

If you want to avoid the temp file in the output of your WMQ command then you may insert its execution in the FOR command, but in this case a temp file is required to provide the input to WMQ command anyway. To do that, change these lines:

Code: Select all

echo "display ql(*)" | runmqsc QMGR > output.txt
for /F "delims=" %%a in (output.txt) do (
by these ones:

Code: Select all

echo "display ql(*)" > input.txt
for /F "delims=" %%a in ('runmqsc QMGR ^< input.txt') do (


Antonio

Re: Data manipulation and alignment

Posted: 06 Nov 2012 03:32
by Mahendra
Excellent solution .....Many thanks for your inputs

Re: Data manipulation and alignment

Posted: 07 Nov 2012 02:53
by Mahendra
@echo off
setlocal EnableDelayedExpansion
echo ---------------------------------------------------------------------------
echo Queue ^| type ^|put ^| get ^|Maxdepth^|cudepth^|usage
echo ----------------------------------------------------------------------------
set details=
echo "display ql(*)" | runmqsc QMGR > output.txt
for /F "delims=" %%a in (output.txt) do (
set details=!details!%%a
set property=%%a
if "!property:usage=!" neq "!property!" (
for /F "tokens=1-14 delims=()" %%a in ("!details!") do (
echo %%b^|%%d^|%%f^|%%h^|%%j^|%%l^|%%n
)
set details=
)
)



Is it possible to print the output as below from the above script to notepad or IE. it should be like a perfect table of contents.
Queue length max 48 chars like type 6 , put 8 maxdepth 7 curdepth 7 usage 7 chars

---------------------------------------------------
Queue -------------------------|type--|put----| get--- |Maxdepth|cudepth|usage
----------------------------------------------------------------------------
system.jdfkjdhfkdj.khkdhfkd------|LOCAL|enabled|enabled|10000----|100----|NORMAL
kjhfksjdfhdkfjhkdsfjds_2323.sdjj---|LOCAL|enabled|disabled|10000----|100----|NORMAL