[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

8418.0. "printing multiple copies..." by QCAV01::NRHEGDE (T&E or R&D !?) Fri Jan 10 1997 01:00

T.RTitleUserPersonal
Name
DateLines
8418.1More info neededNETRIX::"[email protected]"SriFri Jan 10 1997 13:468
8418.2Details provided... printer is xerox printer...QCAV01::NRHEGDET&E or R&D !?Wed Jan 15 1997 06:4117
8418.3Just a loop for it...QCAV02::NRHEGDET&E or R&D !?Mon Mar 03 1997 21:1657
Hello !
     I have used small workaround for this. This C program issues lpr
    command number of times based on the value given for multiple 
    copies.
    
     The usage is same as lpr.
    
     regards
    Nagaraj Hegde
    
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define TRUE  1
#define FALSE 0

main(int argc, char *argv[])
{
	int LOOP = argc, MULTIPLE_COPIES = 0, i = 0;
	int count = 1;
	char command_string[5],system_command[100];
	int Hash_Option = -1;

	if (argc < 2)
	{
		fprintf(stderr,"Usage : lpr  [flags] <filename>\n");
		exit(0);
	}

	while(LOOP)
	{
		if( !strncmp(argv[i],"-#",2))
		{
			MULTIPLE_COPIES=TRUE;
			Hash_Option = i;
			break;
		}
		LOOP--;
		i++;
	}

	if(MULTIPLE_COPIES == TRUE)
		sscanf( argv[i],"-#%d",&count);

	strcpy(system_command,"lpx ");

	for( i = 1; i < argc; i++) {
		if( MULTIPLE_COPIES == TRUE && i == Hash_Option)
			continue;
		strcat(system_command," ");
		strcat(system_command,argv[i]);
	}

	for(i = 0;i < count; i++) {
		system(system_command);
	}
}