Data manipulation and alignment

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Mahendra
Posts: 26
Joined: 23 Sep 2012 02:29

Data manipulation and alignment

#1 Post by Mahendra » 16 Oct 2012 10:07

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.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Data manipulation and alignment

#2 Post by foxidrive » 16 Oct 2012 10:10

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.

Mahendra
Posts: 26
Joined: 23 Sep 2012 02:29

Re: Data manipulation and alignment

#3 Post by Mahendra » 16 Oct 2012 10:17

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.

Mahendra
Posts: 26
Joined: 23 Sep 2012 02:29

Re: Data manipulation and alignment

#4 Post by Mahendra » 16 Oct 2012 10:31

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)

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Data manipulation and alignment

#5 Post by foxidrive » 16 Oct 2012 11:18

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
)

Mahendra
Posts: 26
Joined: 23 Sep 2012 02:29

Re: Data manipulation and alignment

#6 Post by Mahendra » 17 Oct 2012 02:49

Is there any way to print it without using any temp file ?

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Data manipulation and alignment

#7 Post by foxidrive » 17 Oct 2012 05:03

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.

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Data manipulation and alignment

#8 Post by Squashman » 17 Oct 2012 05:42

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.

Mahendra
Posts: 26
Joined: 23 Sep 2012 02:29

Re: Data manipulation and alignment

#9 Post by Mahendra » 17 Oct 2012 21:13

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)

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Data manipulation and alignment

#10 Post by Aacini » 27 Oct 2012 19:54

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

Mahendra
Posts: 26
Joined: 23 Sep 2012 02:29

Re: Data manipulation and alignment

#11 Post by Mahendra » 06 Nov 2012 03:32

Excellent solution .....Many thanks for your inputs

Mahendra
Posts: 26
Joined: 23 Sep 2012 02:29

Re: Data manipulation and alignment

#12 Post by Mahendra » 07 Nov 2012 02:53

@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

Post Reply