M$�� ������ �����ϱ� ���ؼ��� �Ʒ��� �۾��� �� �ؾ߸� �Ѵ�.
a) /etc/printcap ȭ�Ͽ� ���� ���丮 ����(��Ǯ���丮 ��)�� ��Ȯ�� ��ġ�ϴ� ������ ������ �־�� �Ѵ�.
b) /usr/bin/smbprint ȭ���� �־�� �Ѵ�. �� ȭ���� ��� �ҽ��� ���� ���ԵǾ� �ִµ�, ��� ���� ȭ�ϸ��� ����ִ� ���������� �������� �� �ִ�. �� ȭ���� �ణ ������ ���� �Ʒ��� �����Ǿ� �ִ�.
c) ���� �ƽ�Ű ȭ���� ����Ʈ��ũ��Ʈ ȭ�Ϸ� ��ȯ�ϱ� ���ؼ��� nenscript�� �� ���� ������ �ϴ� ���� ������ �־�߸� �Ѵ�. nenscript�� ����Ʈ��ũ��Ʈ ��ȯ���̰� ������ /usr/bin �Ʒ��� ��ġ�ȴ�.
d) ��ٷ� �������Ҷ� ����ϱ� ���� ������ �̿��ϱ⸦ ���� ���̴�. �ƽ�Ű ȭ��, ����Ʈ��ũ��Ʈ ȭ���� ó�����ִ�, �Ǵ� ����Ʈ��ũ��Ʈ ȭ���� �������ִ� �� ��ũ��Ʈ�� �Ʒ��� �־��� �ִ�.
M$ NT ȣ��Ʈ�� HP 5MP ������ ���� /etc/printcap ȭ���� ������ �Ʒ��� �־��� �ִ�. �� ����� ������ �ǹ̰� �ִ�
cm - �ּ�(������ ����) lp - ����� ���� ��ġ�� sd - ���� ��ǻ���� ������ ��Ǯ ���丮 af - the accounting file mx - �ִ� ȭ�� ũ��( 0�� ������ ������ ���Ѵ�) if - �Է� ����(��ũ��Ʈ)�� �̸�
�� ���� ������ ���ϸ� Printing HOWTO�� printcap�� �Ŵ����� ���� �ٶ���
# /etc/printcap
#
# //zimmerman/oreilly via smbprint
#
lp:\
:cm=HP 5MP Postscript OReilly on zimmerman:\
:lp=/dev/lp1:\
:sd=/var/spool/lpd/lp:\
:af=/var/spool/lpd/lp/acct:\
:mx#0:\
:if=/usr/bin/smbprint:
��Ǯ ���丮�� accounting ���丮�� �����ϰ� ���Ⱑ�� ���� ������ ���־�� �Ѵ�. ���� 'if' �ٿ� smbprint ��ũ��Ʈ(�Ʒ��� �־���)�� ��Ȯ�� ��ΰ� �����ִ���, ������ ��ġ�� ����Ű�� �ִ���(/dev �Ʒ��� Ư�� ȭ��)�� Ȯ���ؾ� �Ѵ�.
�������� smbprint ��ũ��Ʈ������ �����̴�. ��ũ��Ʈ�� �밳 /usr/bin �Ʒ��� ��ġ�ϰ�, ��ٸ� ���������� �������� Andrew Tridgell�� ���� ���̴�. �� ��ũ��Ʈ�� ��ټҽ� ���������� ���ԵǾ������� ����ȭ�� ���������� ������� �ʴ�. ���� ����� �ٽ� ����� �� ���̴�.
�� ��ũ��Ʈ�� ���DZ��� ���캼 ������ �������µ�, �� ��ũ��Ʈ�� �׳� �״�� ����ϴ� �ͺ��ٴ� �ڽ��� ȯ�濡 �˸°� �����ϴ� ���� �� �ٶ����ϰ� �����ϴ�.
#!/bin/sh -x
# �� ��ũ��Ʈ�� ���н� �� printcap �������� ���� �Է� �����̴�.
# �̰��� ������ ��� ������ ���� ȭ���� ����Ʈ�ϱ� ���� smbclient
# ���α��� �̿��Ѵ�.
# ���� ��� printcap ������ �Ʒ�ó�� �� �� �ִ�
#
# smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
#
# ���� ������ �� ��ũ��Ʈ�� ���� ����Ʈ�ϴ� "smb" ��� ���н� ������
# �����. ���� ������ ���Ѱ� �������� ���� /usr/spool/smb ��Ǯ���丮��
# ������ �Ѵ�.
#
# ��ũ��Ʈ�� hamiltom@ecnz.co.nz (Michael Hamilton)�� ���ؼ� ����, ����
# ���� ��ȣ�� /usr/var/spool/lpd/PRINTNAME/.config ȭ�Ͽ��� ���� ��
# �ֵ��� �ٲ������.
#
# �̰��� �����ϰ� �ϱ� ���ؼ��� /etc/printcap�� accounting ȭ��(af=...)�� ��
# ���ԵǾ�߸� �Ѵ�.
#
# cdcolour:\
# :cm=CD IBM Colorjet on 6th:\
# :sd=/var/spool/lpd/cdcolour:\
# :af=/var/spool/lpd/cdcolour/acct:\
# :if=/usr/local/etc/smbprint:\
# :mx=0:\
# :lp=/dev/null:
#
# /usr/var/spool/lpd/PRINTNAME/.config ȭ�Ͽ� ���� ������ �����Ѵ�:
# server=PC_SERVER
# service=PR_SHARENAME
# password="password"
#
# E.g.
# server=PAULS_PC
# service=CJET_371
# password=""
#
# Debugging log file, ���Ѵٸ� /dev/null�� �ٲ㵵 �ȴ�.
#
logfile=/tmp/smb-print.log
# logfile=/dev/null
#
# ������ ������ �Ķ���ʹ� accounting ȭ�� �̸��̴�.
#
spool_dir=/var/spool/lpd/lp
config_file=$spool_dir/.config
# config ȭ�Ͽ��� ���� ���� ������ �о� ���δ�.
# server
# service
# password
# user
eval `cat $config_file`
#
# Some debugging help, change the >> to > if you want to same space.
#
echo "server $server, service $service" >> $logfile
(
# ����: ����Ʈ�ÿ� �ڵ����� CR/LF ��ȯ�� �����ϰ� �Ϸ��� `echo translate'��
# �߰��Ѵ�.
echo translate
echo "print -"
cat
) | /usr/bin/smbclient "\\\\$server\\$service" $password -U $user -N -P >> $logfile
��κ��� ������ �������� �ƽ�Ű ������ ����Ʈ��ũ��Ʈ�� ��ȯ���ִ� nenscript�� ������ �ִ�. ���� perl ��ũ��Ʈ�� smbprint�� ���� ���������� ����Ʈ�ϴ� ���� ���� ���� ���ش�.
Usage: print [-a|c|p] <filename> -a prints <filename> as ASCII -c prints <filename> formatted as source code -p prints <filename> as Postscript If no switch is given, print attempts to guess the file type and print appropriately.
�ƽ�Ű ȭ���� ����Ʈ�ϱ� ���ؼ� smbprint�� �̿��Ҷ� �� ���� �߸��� ��찡 �ִ�. �� ��ũ��Ʈ�� �����ϴٸ� �� ���� �ܾ� �߰��� �߸��� ��ſ� ���鿡�� �߸����� ���ش�.
nenscript�� �ҽ��ڵ忡 ������ �ش�. ������� �Ӹ���(��¥, ȭ���̸� ��)�� �߰��Ͽ� �ƽ�Ű ȭ�ϰ� ������ �����Ѵ�. ����, �ٹ�ȣ�� �ű��. �Ʒ� ���� �̿��Ͽ� �ٸ� ����� ���ĵ� �����ϴ�.
����Ʈ��ũ��Ʈ ������ �̹� ������ ������ ������ �����Ƿ� ���� ����� �ȴ�.
#!/usr/bin/perl
# Script: print
# Authors: Brad Marshall, David Wood
# Plugged In Communications
# Date: 960808
#
# Script to print to oreilly which is currently on zimmerman
# ����: �������� ������ ȭ�ϵ��� ���ڷμ� �Ƶ鿩 ��� ����Ʈ ��ũ��Ʈ��
# �������� �����µ� �����ϰ� ó���� �Ѵ�.
#
# ������ ȭ�� ����:
#
# ASCII - $line_length ���� �� �� ���ڵ��� �������� �� ���̸� �����Ѵ�.
# Postscript - �ƹ��� ó���� ���� �ʴ´�.
# Code - �����ϰ�(��¹���, ���ڸ�� ��) ����ϱ� ���ؼ� nenscript��
# �̿��Ͽ� ����Ʈ��ũ��Ʈ ������ �����.
#
# �ƽ�Ű �ؽ�Ʈ �������� �� �ٴ� �ִ� ���ڼ�.
$line_length = 76;
# ��� ����Ʈ ��ũ��Ʈ�� ��ο� �̸�.
$print_prog = "/usr/bin/smbprint";
# nenscript�� ��ο� �̸�(�ƽ�Ű-->����Ʈ��ũ��Ʈ ��ȯ��)
$nenscript = "/usr/bin/nenscript";
unless ( -f $print_prog ) {
die "Can't find $print_prog!";
}
unless ( -f $nenscript ) {
die "Can't find $nenscript!";
}
&ParseCmdLine(@ARGV);
# DBG
print "filetype is $filetype\n";
if ($filetype eq "ASCII") {
&wrap($line_length);
} elsif ($filetype eq "code") {
&codeformat;
} elsif ($filetype eq "ps") {
&createarray;
} else {
print "Sorry..no known file type.\n";
exit 0;
}
# smbprint�� �� �ٵ��� ����(���)��Ų��.
open(PRINTER, "|$print_prog") || die "Can't open $print_prog: $!\n";
foreach $line (@newlines) {
print PRINTER $line;
}
# ȭ���� ������ ���� ����� ������ ���� ��쿡 �ٹٲ�(�����ǵ�)�� �߰��Ѵ�.
print PRINTER "\n";
close(PRINTER);
print "Completed\n";
exit 0;
# --------------------------------------------------- #
# Everything below here is a subroutine #
# --------------------------------------------------- #
sub ParseCmdLine {
# �ڸǵ� ������ �м��ؼ� ȭ���� ������ �������� ã�Ƴ���.
# $arg�� $file �� �ִٸ� ���� ��´�.
# and the filename
if ($#_ < 0) {
&usage;
}
# DBG
# foreach $element (@_) {
# print "*$element* \n";
# }
$arg = shift(@_);
if ($arg =~ /\-./) {
$cmd = $arg;
# DBG
# print "\$cmd found.\n";
$file = shift(@_);
} else {
$file = $arg;
}
# ȭ�� ������ �����Ѵ�.
unless ($cmd) {
# �ƹ��� ���ڰ� ���� ���.
if ($file =~ /\.ps$/) {
$filetype = "ps";
} elsif ($file =~ /\.java$|\.c$|\.h$|\.pl$|\.sh$|\.csh$|\.m4$|\.inc$|\.html$|\.htm$/) {
$filetype = "code";
} else {
$filetype = "ASCII";
}
# $file�� ȭ�������� �������� �˾Ƴ��� $filetype�� �Ѱ��ش�.
} else {
# We have what type it is in $arg
if ($cmd =~ /^-p$/) {
$filetype = "ps";
} elsif ($cmd =~ /^-c$/) {
$filetype = "code";
} elsif ($cmd =~ /^-a$/) {
$filetype = "ASCII"
}
}
}
sub usage {
print "
Usage: print [-a|c|p] <filename>
-a prints <filename> as ASCII
-c prints <filename> formatted as source code
-p prints <filename> as Postscript
If no switch is given, print attempts to
guess the file type and print appropriately.\n
";
exit(0);
}
sub wrap {
# �ٱ��̰� ������ ���ڼ����� ������ ȭ���� �� ���� �迭�� �Ҵ��Ѵ�.
# ������ �̿��� �ٱ��̸� �����Ѵ�.
# �ٱ��̸� ������ ���ڼ��� ���� ��´�.
$limit = pop(@_);
# DBG
#print "Entering subroutine wrap\n";
#print "The line length limit is $limit\n";
# ȭ���� �о�鿩 �м��ϰ� �� ���� �迭�� �Ҵ��Ѵ�.
open(FILE, "<$file") || die "Can't open $file: $!\n";
while(<FILE>) {
$line = $_;
# DBG
#print "The line is:\n$line\n";
# ���ѱ��̺��� �� ���� ���̸� �����Ѵ�.
while ( length($line) > $limit ) {
# DBG
#print "Wrapping...";
# $limit +1 ������ ���ڵ��� ��´�.
$part = substr($line,0,$limit +1);
# DBG
#print "The partial line is:\n$part\n";
# ������ ���ڰ� �������� �ƴ����� �����Ѵ�.
$last_char = substr($part,-1, 1);
if ( " " eq $last_char ) {
# �����̶�� �״�� ����Ѵ�.
# DBG
#print "The last character was a space\n";
substr($line,0,$limit + 1) = "";
substr($part,-1,1) = "";
push(@newlines,"$part\n");
} else {
# ������ �ƴ϶�� ������ ������ ��ġ��
# ã�� �װ����� ����Ѵ�.
# DBG
#print "The last character was not a space\n";
# $limit ������ ���ڸ� �����.
substr($part,-1,1) = "";
# ������ ������ ã�� ���� ���� �����´�.
$revpart = reverse($part);
$index = index($revpart," ");
if ( $index > 0 ) {
substr($line,0,$limit-$index) = "";
push(@newlines,substr($part,0,$limit-$index)
. "\n");
} else {
# ������ �������� ���� ���̶��
# $limit ���� ����� �Ѵ�.
substr($line,0,$limit) = "";
push(@newlines,substr($part,0,$limit)
. "\n");
}
}
}
push(@newlines,$line);
}
close(FILE);
}
sub codeformat {
# �����ƾ wrap�� ȣ���ؼ� nenscript�� ���� ������ �Ѵ�.
&wrap($line_length);
# �ҽ� �ڵ带 ����Ʈ�ϱ� ���� ��� �˸��� ���ĵ�(��������,
# Courier font, �ٹ�ȣ)�� ���Խ�Ų ����Ʈ��ũ��Ʈ ȭ���� ����
# �ϱ� ���ؼ� nenscript�� ����� ó���Ѵ�.
# ù��°�� �ӽ�ȭ�Ϸ� ����Ѵ�.
$tmpfile = "/tmp/nenscript$$";
open(FILE, "|$nenscript -2G -i$file -N -p$tmpfile -r") ||
die "Can't open nenscript: $!\n";
foreach $line (@newlines) {
print FILE $line;
}
close(FILE);
# �ӽ� ȭ���� �ٽ� �о�鿩�� ��� ����Ʈ ��ũ��Ʈ�� �����
# �� �ֵ��� �迭�� �����Ѵ�.
@newlines = ("");
open(FILE, "<$tmpfile") || die "Can't open $file: $!\n";
while(<FILE>) {
push(@newlines,$_);
}
close(FILE);
system("rm $tmpfile");
}
sub createarray {
# ����Ʈ��ũ��Ʈ�� ���� �迭�� �����Ѵ�.
open(FILE, "<$file") || die "Can't open $file: $!\n";
while(<FILE>) {
push(@newlines,$_);
}
close(FILE);
}