LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-22-2012, 03:55 AM   #1
famedoro
LQ Newbie
 
Registered: May 2012
Posts: 16

Rep: Reputation: Disabled
Linux script related to printer


Is it possible in a Linux system with cups insert a script related to a specific printer (special/virtual) so to write its content on a file before print it?
 
Old 05-22-2012, 04:20 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,629

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
maybe this helps: http://en.opensuse.org/SDB:Using_You...rint_with_CUPS
 
1 members found this post helpful.
Old 05-22-2012, 05:31 AM   #3
famedoro
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
More filters

Is it possible to add more filters in same ppd file ? One for send job to printer and one for write the same content to file ?
 
Old 05-22-2012, 05:42 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,629

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
you can add a shell script as a filter and you can save the file and also send back to cups for processing. Or you can modify the original plain text filter to save files.
 
Old 05-22-2012, 05:51 AM   #5
famedoro
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
you can add a shell script as a filter and you can save the file and also send back to cups for processing. Or you can modify the original plain text filter to save files.
Can you give me an example?
 
Old 05-22-2012, 06:09 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,629

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
http://eloquence.marxmeier.com/sdb/html/1123683643.html

see the trivial example:
Code:
#! /bin/sh

# Command line arguments
job="$1"
user="$2"
title="$3"
numcopies="$4"
options="$5"
filename="$6"

# Pass through
cp "$filename" "<saved filename>" # < new line
cat "$filename"
 
Old 05-22-2012, 06:47 AM   #7
famedoro
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
http://eloquence.marxmeier.com/sdb/html/1123683643.html

see the trivial example:
Code:
#! /bin/sh

# Command line arguments
job="$1"
user="$2"
title="$3"
numcopies="$4"
options="$5"
filename="$6"

# Pass through
cp "$filename" "<saved filename>" # < new line
cat "$filename"
Thanks for you response.

I have some question:
1) In what directory should I create the script? (/ etc / cups / interfaces?, but currently this directory is empty although there are several printers installed)
2) How do I configure the ppd file in order to get him to use the script ?

Thanks for your help.
 
Old 05-22-2012, 07:16 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,629

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
this is mainly described on the link I gave you, see lpadmin.
 
Old 05-22-2012, 08:50 AM   #9
famedoro
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
this is mainly described on the link I gave you, see lpadmin.
I tried it and it works. The problem is that it writes a file in postscript format, while I wish it were plain text.

Thanks for your help.
 
Old 05-22-2012, 09:23 AM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,568

Rep: Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865
What is the application creating the file?
 
Old 05-22-2012, 09:27 AM   #11
famedoro
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
What is the application creating the file?
I've used the print test page, and I've obtained this:
%!PS-Adobe-3.0
%%BoundingBox: 0 0 612 792
%%Pages: 1
%%LanguageLevel: 1
%%DocumentData: Clean7Bit
%%DocumentSuppliedResources: procset testprint/1.0
%%DocumentNeededResources: font Helvetica Helvetica-Bold Times-Roman
%%Creator: Michael Sweet, Easy Software Products
%%CreationDate: May 11, 1999
%%Title: Test Page
%%EndComments
%%BeginProlog
%%BeginResource procset testprint 1.1 0
%
% PostScript test page for the Common UNIX Printing System ("CUPS").
%
% Copyright 1993-2001 Easy Software Products
%
% These coded instructions, statements, and computer programs are the
% property of Easy Software Products and are protected by Federal
% copyright law. Distribution and use rights are outlined in the file
% "LICENSE.txt" which should have been included with this file. If this
% file is missing or damaged please contact Easy Software Products
% at:
...
2 copy moveto % Position text
(Easy Software Products, 44141 Airport View Drive, Suite 204,) CENTER
pageHeight sub % Move down...
2 copy moveto % Position text
(Hollywood, Maryland, 20636-3111, USA.) CENTER

% Then the CUPS logo....
gsave
pageWidth 4 mul
pageHeight 4 mul
translate
pageWidth 9 mul CUPSLOGO
grestore

% And the ESP logo....
gsave
pageWidth 59 mul
pageHeight 4 mul
translate
pageWidth 6 mul ESPLOGO
grestore
% Show the page...
grestore
 
Old 05-22-2012, 09:47 AM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,568

Rep: Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865
That is because the test page is Postscript. Since the filter will not convert file formats what are you trying to accomplish?
 
Old 05-22-2012, 09:51 AM   #13
famedoro
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
That is because the test page is Postscript. Since the filter will not convert file formats what are you trying to accomplish?
I have tried to print out a page of plain text, but I always get postscript.
I want to get two things:
print the file and store the file printed.

Thanks for your help.
 
Old 05-22-2012, 10:03 AM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,568

Rep: Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865Reputation: 5865
This is normal. What application are you using to create/open the file? It depends on the application but most will generate a PS file when you select to print. So in fact you are storing the file printed. If you want the stored file to be readable you could convert it to PDF in your filter.
 
Old 05-23-2012, 02:37 AM   #15
famedoro
LQ Newbie
 
Registered: May 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
This is normal. What application are you using to create/open the file? It depends on the application but most will generate a PS file when you select to print. So in fact you are storing the file printed. If you want the stored file to be readable you could convert it to PDF in your filter.
I can't accomplish this since my goal is to provide file in pure raw text with print to a
program for processing
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Samba/CUPS related Printer addition issue fedfan Linux - Server 0 03-03-2012 11:38 AM
Virtual printer? (take content to custom shell script/program/another printer) dedec0 Programming 7 07-12-2011 06:18 PM
issue related to shell script manglesh.vyas Linux - Newbie 2 12-07-2010 05:39 PM
Need a script help related to Kernel sharp859 Programming 3 04-17-2009 12:00 PM
shell script (bind related) OTIM Programming 6 07-10-2008 04:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration