Sponsored Content
Full Discussion: Problem with printing
Top Forums Shell Programming and Scripting Problem with printing Post 302390065 by Cheranime on Tuesday 26th of January 2010 09:38:48 PM
Old 01-26-2010
Problem with printing

Hi, i am writing a script to generate a summary report for my data text file
my data in my text file goes like this:
Code:
MacOS:Mary Abraham:53.48:88:38
Windows in lala:Mary Abraham:22.30:23:22
lala in Windows:John Goodman:33.60:121:12
Hello world:Mr Tian:23.30:23:10
Windows in 31 days:John Badman:33.70:212:13

and this is my code to print the data out
Code:
BEGIN{
 FS=":"
 print " " 
 print "===================================Summary Report================================================="
 print "=================================================================================================="
 print "|Title          | \tAuthor                   \t|Price \t|Qty Available|Qty Sold|Total|"
 print "=================================================================================================="
}
{
        title = $1
        author = $2
        price = $3
        available = $4
        sold = $5
        total = $3 * $5
 printf("%s\t                   %s\t$%s\t\t%s\t%s\t$%s\n", title, author, price, available, sold, total)
 
}
END{
 }

the output will be
Image

I will like to know is there any ways I can change my code to make sure that the data in each column will align properly under the respectively title? Thank You
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Problem with printing

Hi , Can somebody Please help me in finding out where I am going wrong. Suppose i have a file called r_wer which contains files. for ex : LMN20001 LMN20002 LMN20003 Now I want to print them. The way I am doing is $ for a in `cat '/r_wer'` > do > lp -d printername $a > done But... (3 Replies)
Discussion started by: rooh
3 Replies

2. UNIX for Dummies Questions & Answers

printing problem

i can only print from unix when I am logged in as host. When any user logs in (even myself as a user who has root priviledges) I cannot print. Has anyone heard of this problem before and are there any troubleshooting tips out there. HELP......... (3 Replies)
Discussion started by: acarroll
3 Replies

3. IP Networking

Printing Problem

I have a printer installed on sun solaris m/c sun os 5.8. It doesn't print more than 52 files i.e if a give lp *.txt and the curent folder contains more than 52 files then it doesn't print them but if print in batches , each containing 52 files then it prints them properly. How do i increase the... (3 Replies)
Discussion started by: kapilv
3 Replies

4. UNIX for Dummies Questions & Answers

printing Problem

When I print a file from an application it never stops printing. Any ideas? (2 Replies)
Discussion started by: 744eagle
2 Replies

5. UNIX for Dummies Questions & Answers

Printing problem in the Unix

How do you print a batch of pdf files on solaris 8/9 to a post script printer(HPLaser 4350).so that printing is as both sides of the paper.We have tried to print using XPDF pdftops program but we are able to print only as one side. The switch -o duplex does not seem to work when used with lp... (1 Reply)
Discussion started by: sivamurugan
1 Replies

6. HP-UX

Urgent printing problem

I can no longer print from HP-UX 10. All the printers are network printers. I have already stopped and restarted the spooler (lpshut and lpsched), but still the same problem. The printers react when I ping them. I have also tried with SAM, but the system cannot find the printers. Can somebody... (1 Reply)
Discussion started by: filipd
1 Replies

7. UNIX for Dummies Questions & Answers

Printing problem

Hello, Not sure where to begin on describing the issue; please try to understand that I am not very familiar with SCO UNIXWARE. I am a newbie... We have a SCO UNIXWARE version 7.4 when we restart the computer we are required to enter the command lpstart, without it; people cannot print. ... (1 Reply)
Discussion started by: Yorgy
1 Replies

8. UNIX for Advanced & Expert Users

Printing Problem

I am trying to print to an hp printer. i configured it using the hp configuration, entry is in the /etc/hosts file, i can telnet into it using port 9100, ping it and send jobs to it. it just won't print. the jobs stay in the spooler. its telling me to add the printer to the canaccess list. ... (0 Replies)
Discussion started by: Rosario
0 Replies

9. HP-UX

Printing problem

I have scheduled to print a numerous of report in mid-night. But, I found that some reports have not been printed out. Then, I checked the file /var/spool/lp/log and found that all reports have been submitted to print queue. Could anyone tell me what can be done to ensure all print jobs can be... (2 Replies)
Discussion started by: alfredo
2 Replies

10. SCO

Problem with printing

Does anybody know how I can stop the system slewing pages when a spool file has finished printing. I need to set up a method where all users are printing to the same printer to produce labels. The problem is that when the first users file has been printed the pages are slewed and the label is not... (2 Replies)
Discussion started by: rongrout
2 Replies
Template::View(3)					User Contributed Perl Documentation					 Template::View(3)

NAME
Template::View - customised view of a template processing context SYNOPSIS
# define a view [% VIEW view # some standard args prefix => 'my_', suffix => '.tt2', notfound => 'no_such_file' ... # any other data title => 'My View title' other_item => 'Joe Random Data' ... %] # add new data definitions, via 'my' self reference [% my.author = "$abw.name <$abw.email>" %] [% my.copy = "&copy; Copyright 2000 $my.author" %] # define a local block [% BLOCK header %] This is the header block, title: [% title or my.title %] [% END %] [% END %] # access data items for view [% view.title %] [% view.other_item %] # access blocks directly ('include_naked' option, set by default) [% view.header %] [% view.header(title => 'New Title') %] # non-local templates have prefix/suffix attached [% view.footer %] # => [% INCLUDE my_footer.tt2 %] # more verbose form of block access [% view.include( 'header', title => 'The Header Title' ) %] [% view.include_header( title => 'The Header Title' ) %] # very short form of above ('include_naked' option, set by default) [% view.header( title => 'The Header Title' ) %] # non-local templates have prefix/suffix attached [% view.footer %] # => [% INCLUDE my_footer.tt2 %] # fallback on the 'notfound' template ('my_no_such_file.tt2') # if template not found [% view.include('missing') %] [% view.include_missing %] [% view.missing %] # print() includes a template relevant to argument type [% view.print("some text") %] # type=TEXT, template='text' [% BLOCK my_text.tt2 %] # 'text' with prefix/suffix Text: [% item %] [% END %] # now print() a hash ref, mapped to 'hash' template [% view.print(some_hash_ref) %] # type=HASH, template='hash' [% BLOCK my_hash.tt2 %] # 'hash' with prefix/suffix hash keys: [% item.keys.sort.join(', ') [% END %] # now print() a list ref, mapped to 'list' template [% view.print(my_list_ref) %] # type=ARRAY, template='list' [% BLOCK my_list.tt2 %] # 'list' with prefix/suffix list: [% item.join(', ') %] [% END %] # print() maps 'My::Object' to 'My_Object' [% view.print(myobj) %] [% BLOCK my_My_Object.tt2 %] [% item.this %], [% item.that %] [% END %] # update mapping table [% view.map.ARRAY = 'my_list_template' %] [% view.map.TEXT = 'my_text_block' %] # change prefix, suffix, item name, etc. [% view.prefix = 'your_' %] [% view.default = 'anyobj' %] ... DESCRIPTION
TODO METHODS
new($context, \%config) Creates a new Template::View presenting a custom view of the specified $context object. A reference to a hash array of configuration options may be passed as the second argument. prefix Prefix added to all template names. [% USE view(prefix => 'my_') %] [% view.view('foo', a => 20) %] # => my_foo suffix Suffix added to all template names. [% USE view(suffix => '.tt2') %] [% view.view('foo', a => 20) %] # => foo.tt2 map Hash array mapping reference types to template names. The print() method uses this to determine which template to use to present any particular item. The TEXT, HASH and ARRAY items default to 'test', 'hash' and 'list' appropriately. [% USE view(map => { ARRAY => 'my_list', HASH => 'your_hash', My::Foo => 'my_foo', } ) %] [% view.print(some_text) %] # => text [% view.print(a_list) %] # => my_list [% view.print(a_hash) %] # => your_hash [% view.print(a_foo) %] # => my_foo [% BLOCK text %] Text: [% item %] [% END %] [% BLOCK my_list %] list: [% item.join(', ') %] [% END %] [% BLOCK your_hash %] hash keys: [% item.keys.sort.join(', ') [% END %] [% BLOCK my_foo %] Foo: [% item.this %], [% item.that %] [% END %] method Name of a method which objects passed to print() may provide for presenting themselves to the view. If a specific map entry can't be found for an object reference and it supports the method (default: 'present') then the method will be called, passing the view as an argument. The object can then make callbacks against the view to present itself. package Foo; sub present { my ($self, $view) = @_; return "a regular view of a Foo "; } sub debug { my ($self, $view) = @_; return "a debug view of a Foo "; } In a template: [% USE view %] [% view.print(my_foo_object) %] # a regular view of a Foo [% USE view(method => 'debug') %] [% view.print(my_foo_object) %] # a debug view of a Foo default Default template to use if no specific map entry is found for an item. [% USE view(default => 'my_object') %] [% view.print(objref) %] # => my_object If no map entry or default is provided then the view will attempt to construct a template name from the object class, substituting any sequence of non-word characters to single underscores, e.g. # 'fubar' is an object of class Foo::Bar [% view.print(fubar) %] # => Foo_Bar Any current prefix and suffix will be added to both the default template name and any name constructed from the object class. notfound Fallback template to use if any other isn't found. item Name of the template variable to which the print() method assigns the current item. Defaults to 'item'. [% USE view %] [% BLOCK list %] [% item.join(', ') %] [% END %] [% view.print(a_list) %] [% USE view(item => 'thing') %] [% BLOCK list %] [% thing.join(', ') %] [% END %] [% view.print(a_list) %] view_prefix Prefix of methods which should be mapped to view() by AUTOLOAD. Defaults to 'view_'. [% USE view %] [% view.view_header() %] # => view('header') [% USE view(view_prefix => 'show_me_the_' %] [% view.show_me_the_header() %] # => view('header') view_naked Flag to indcate if any attempt should be made to map method names to template names where they don't match the view_prefix. Defaults to 0. [% USE view(view_naked => 1) %] [% view.header() %] # => view('header') print( $obj1, $obj2, ... \%config) TODO view( $template, \%vars, \%config ); TODO AUTHOR
Andy Wardley <abw@wardley.org> <http://wardley.org/> COPYRIGHT
Copyright (C) 2000-2007 Andy Wardley. All Rights Reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO
Template::Plugin perl v5.16.3 2012-01-23 Template::View(3)
All times are GMT -4. The time now is 03:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy