Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with printing and removing files with a script

Status
Not open for further replies.

hilarity

Programmer
Jul 24, 2001
9
0
0
FR
My problem is as follows: I print f.e. 5 files (using lp). Then I remove these 5 files (using rm). Only the first 2 files are printed.

I need to have some mechanism in my script that makes sure the files are actually printed before it starts removing them.

Any help would be greatly appreciated...
 
Most of the printer commands contain a -c flag to make a copy of the file
as it currently is so you can remove it later....The down size is that the /var
directory grows...and you have to have enough space


enq command:
-c
Copies the file. To save disk space, the enq command remembers
the name of the file, but does not actually copy the file itself. Use
the -c flag if you want to continue changing the file while you are
waiting for the current copy to be printed.

lp command:


-c
Copies the files to be printed immediately when the lp command is run.
The lp command copies files only when requested. No links are created. If
you specify the -c flag, be careful not to remove any of the files before they
are printed. If you do not specify the -c flag, changes made to the files after
the request is made appear in the printed output.
 
If the timing of the prints is not critical could you put a sleep command (sleep [no of seconds to sleep]) between each of your lp commands to ensure your print has time to complete before being rm'd?
 
Depending on the circumstances you might be able to use a "wait" command in between the lp and the rm
 
Aixqueen's suggestion to use
[tt]
lp -c file_to_print
[/tt]

is definitely the way to go - it tells lp to take a copy of the file rather than printing from the file itself. So there's no problem if the original file is deleted before printing start.

You do, as she says, have to have enough free space in your spool directory.... Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Thanks everybody for your help. I'll use the -c option.

hilarity.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top