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);
}