Operating System - HP-UX
1837896 Members
3359 Online
110122 Solutions
New Discussion

Re: script output columns

 
SOLVED
Go to solution
jerry1
Super Advisor

script output columns

Does anyone know how to make these columns
come out striaght. Here is the output and
the code is below. I'm not much on tclsh.

--------------
Count of problem log files during Email collection

Tester Site Errors

ats182 Irving 0
ats182 Seattle 0
ats182 BESC 0
ats182 EPSC 0
ats195 Seattle 0
ats195 BESC 0
ats195 Irving 0
ats195 ASPC 0
----------------------------

#!/usr/bin/sh
# Comment with backslash required here. \
exec ${TCL_HOME}/bin/tclsh "$0" "$@"
set CB $env(CollectBox);
proc CountSite {Tester SubDir} {
set Count [open "| find $SubDir -type f |
wc"];
gets $Count cnt;
close $Count;
puts "$Tester \t[file tail $SubDir] \t[lindex $cnt 0]" ;
}
puts "\nCount of problem log files during Email collection\n";
puts "Tester\t\tSite \t\tErrors\n";
foreach Tester [glob $CB/*] {
if [file exists $Tester/Oops] {
foreach SubDir [glob -nocomplain $Tester/Oops/TST/*] {
CountSite [file tail $Tester] $SubDir;
}
}
}
2 REPLIES 2
VK2COT
Honored Contributor
Solution

Re: script output columns

Hello,

If I understand your question correctly,
you want to format the output from the
script execution.

Then, you do not use command puts alone but add
format to it. Something like:

puts [format "%7s\t%10s\t%s\n" $Tester $[file tail $SubDir] $[lindex $cnt 0]]

The format command returns a string that is
sent to the standard output device with the
puts command.

Cheers,

VK2COT

VK2COT - Dusan Baljevic
jerry1
Super Advisor

Re: script output columns

Thanks, that looks better. I could not find
any man tclsh reference to "format". Do you
know where this is documented. Also, I had
to take out the $'s next to [file and
[lindex you had or it would print $'s next
to the output value. I just have to work on
the header columns now.

puts [format "%7s\t%10s\t%s\n" $Tester [file tail $SubDir] [lindex $cnt 0]] ;


Tester Site Oopsies

ats182 Irving 0

ats182 Seattle 0

ats182 BESC 0

ats182 EPSC 0

ats195 Seattle 0

ats195 BESC 0

ats195 Irving 0