  SMB HOWTO
  David Wood, dwood@plugged.net.au
  v1.0, 10 August 1996
  앐Y nakano@apm.seikei.ac.jp
  v1.0j1, 24 September 1996

   SMB HOWTO łB̕ Linux  Session Message Block (SMB)
  vgR@ɂďqׂ̂łBSMB vgŔA NetBIOS
  vgRALanManager vgRƂĂ΂Ă܂B

  : ͂̕ȂȑOɏꂽ̂Ȃ̂ŁA܂ǂ Linux 
  ɂ͂Ă͂܂Ȃӏ܂B (JF Project)
  ______________________________________________________________________

  ڎ

  1. ͂߂
  2. ̏
  3. CXg[
  4. f[N
  5. /etc/smb.conf ̐ݒ
  6. Linux ̃hCu Windows }V狤L
  7. Windows ̃hCu Linux }VŋL
  8. Linux }Ṽv^ Windows }V痘p
  9. Linux }V Windows ̃v^g
  10. 쌠
  11. ӎ

  ______________________________________________________________________

  1.  ͂߂

   SMB HOWTO łB̕ Linux  Session Message Block (SMB)
  vgR@ɂďqׂ̂łBSMB vgŔA NetBIOS
  vgRALanManager vgRƂĂ΂Ă܂B

  ̕ David Wood (dwood@plugged.net.au) ҏWĂ܂Bǉ
  CAɂẴ[́ÃAhX܂ł肭Ύ
  ̃[Xɔf܂B

  SMB vgR Microsoft Windows 3.11ANTA95 ŃfBXNv^
  L邽߂ɗp܂BAndrew Tridgell ɂďꂽ Samba
  c[Zbgp΁ALinux Ȃǂ Unix }Vł Windows ̃zXg
  ƃfBXNv^Lł܂B

  Samba pĂł邱Ƃ͈ȉ 4 łB

  1. Linux zXg̃hCu Windows zXgŋLB

  2. Windows zXg̃hCu Linux zXgŋLB

  3. Linux zXg̃v^ Windows zXgŋLB

  4. Windows zXg̃v^ Linux zXgŋLB

  ͈̕ȏ̃P[XׂăJo[Ă܂B

  Ɛ: ̕ɋL@XNvǵA҂܂߂l̃O[v
  ̒ł͂܂Ă܂BقȂƁA܂Ȃ\
  ܂B̂悤ȏꍇ͒҂Ƀ[Œm点Ă΁A̕
  ̔Wɖ𗧂܂B҂͉̕ۏ؂܂B҂Ă
  łH҂͂ĂɂȂ̂ł...
  2.  ̏

   HOWTO ł́ALinux }V SMB ̃t@CT[rXAvg
  T[rX𗘗p邽߂̐ݒ@ɂāAbĂ܂BSamba
  ͕Gō@\ȃVXeł̂ŁA̕ł Samba Ɋւ񂷂
  ĂLq邱Ƃ͂ł܂񂵁A܂̂܂B

  葽̏m肽l͈ȉ݂̕ĂB

  o  Samba ̔zzpbP[WɊ܂܂hLgBzzpbP[W
     <ftp://nimbus.anu.edu.au/pub/tridge/samba/> 擾ł܂B

  o  Linux Printing HOWTO

  o  Print2Win mini HOWTO

  ======

   Samba ~[T[oƂẮA
  <ftp://ring.aist.go.jp/archives/net/samba/> <ftp://ring.asahi-
  net.or.jp/archives/net/samba/> Ȃǂ܂B̖|Ă
  '96 9 ݂ł́A1.9.16p2 ŐṼ[Xo[Ŵ悤łB

  {̉ƂĂ͈ȉ̂悤Ȃ̂܂B
  1.9.15p8 x[XɏĂ܂̂ŁA1.9.16p2 łׂ͍ȕς
  Ă܂B nmbd ̈ԕςĂ̂ŁAman nmbd Ă
  Ƃ߂܂B

  o  Unix Magazine '96 3  wW PC UNIXxRFAЎRP

  o  Unix User '96 10 ` wvCEp[\i Linuxx^hm

  o  wt Samba ̎gx 
     <ftp://etlport.etl.go.jp/pub/windows/knowhow/samba.txt>
      Samba hLgƂĂ̓oCuI݂ƌ܂傤B

  o  D Samba Web y[W
     smb.conf ̖|Ȃǂ܂B

  j[Xł́Apł comp.protocols.smb  Samba Ɋւc_
  Ă܂B

  ==󒍏I==

  3.  CXg[

  ŐV Samba ̃\[X <ftp://nimbus.anu.edu.au/pub/tridge/samba/> 
  瓾܂B

  Redhat gĂlȂ Samba  rpm `ŃCXg[邱Ƃ
  ܂B̔zzpbP[Wɂ Samba ̃oCiCXg[\Ȃ
  ̂܂B

  ======

  {̃t@CLɂꍇ́ARpC̍ۂ Makefile ł
  ݒ肪KvɂȂ܂BL̂悤ȃoCipbP[Wœ{t@C
  LɂȂĂ邩ǂAm̕Ⴂ܂҂܂ł
  m点΍KłB

  ==󒍏I==

  Samba 𗘗p邽߂ɂ͈ȉ 2 ̃f[vOKvłB
  ͒ʏ /usr/sbin ɃCXg[AVXeNɃu[gAbv
  XNvgŋN邩A܂ inetd s܂BXNvg
  ́A``f[N'' ̐߂ɂĂ܂B

     smbd
        SMB f[łB

     nmbd
        NCAg NetBIOS ɂ閼O@\񋟂܂B

  ȉ Samba vO͒ʏ /usr/bin ɃCXg[܂ȉ
  ͑I\łjB

     smbclient
        UNIX zXĝ߂ SMB NCAgvO

     smbprint
        SMB zXg̃v^𗘗p邽߂̃XNvg

     smbprint.sysv
        SVR4 p smbprint

     smbstatus
        [JzXgւ SMB ڑXgvO

     smbrun
        SMB zXgŕKvȃAvP[Vs邽߂̕⏕IȖ
        XNvgvO

  ɁA HOWTO ɂ print ƂÕXNvgĂ
  B smbprint XNvg̃tgGhŁAȒPɂ
  ̂łB

  Samba ̃pbP[WCXg[̂͊ȒPłBL URL \[
  XɓAzzA[JCu̒ README t@CĂB܂
  docs/INSTALL.txt ɂ̓CXg[菇̏ڍׂȉĂ܂B

  CXg[ɑāAf[ /usr/sbin ցAvO /usr/bin
  ցAman y[W /usr/local/man ɒu܂傤B

  Samba ̃pbP[WƂAsmbd ̃RtBM[Vt@C
   smb.conf ̒uꏊ Makefile ̒Ŏw肵܂BDȂƂɒu
  Ƃł܂Aʏ /etc/smb.conf ǂł傤BOt@C
  ƃbNfBNgɂĂ͈ȉ̂悤ɐݒ肵ĂƂ߂
  B

  ______________________________________________________________________
     log file=/var/log/samba-log.%m
     lock directory = /var/lock/samba
  ______________________________________________________________________

  ======

  Samba pbP[W̃ftHg̐ݒł́Af[уvO
  /usr/local/samba/bin ցA܂ smb.conf Ȃǂ /usr/local/samba/lib 
  u܂B

  ܂ log file  lock directory ̐ݒ Makefile łł܂
  Asmb.conf ɏĂhLgȂ̂ŗǂƎv
  B

  ==󒍏I==

  smb.conf CXg[܂BSamba ̃vORpCfB
  NgɍsA example/simple fBNgɈړ README 
  ǂŉBăfBNgɂ smb.conf  /etc ɃRs[
  BłƒӁB Redhat Ȃǂ̔zzpbP[W Samba C
  Xg[ꍇɂ́A /etc  smb.conf 邩܂B
  ꍇ́Ãt@Cݒ͂߂Ɨǂł傤B

  % smb.conf  /etc ɒuȂꍇɂ́ADȏꏊɂăV{
  bNN /etc ɍ܂傤B

  ______________________________________________________________________
      ln -s /path/to/smb.conf /etc/smb.conf
  ______________________________________________________________________

  4.  f[N

  SMB ̃f[ /usr/sbin/smbd  /usr/sbin/nmbd  2 łB

  Samba ̃f[s肩 2 ܂Binetd N
  @ƁAX^hA[̃vZXƂċN@łBp̃t@C
  T[oƂėpꍇ inetd Nǂł傤B
  Ή炩̗Rł̃f[vZXłÃNGXg
  čĎs܂BSMB T[oT[rXXpȂiVXe
  Ǘ̂ƂƂjȂ΁A/etc/rc.d/init.d XNvgs
  ǂł傤BKvȂƂ蓮ŎsĂǂł傤B

  ======

  Xs[h̓_́Af[vZX̕킸ȂLƂӌ
  ܂B܂A҂̃zXg 3 ق Samba gpԁA
  Ƃ͂܂łB

  ==󒍏I==

  inetd f[Nꍇ́Aȉ̍s inetd ̐ݒt@C
  /etc/inetd.conf ɉ܂B

  ______________________________________________________________________
  # SAMBA NetBIOS services (for PC file and print sharing)
  netbios-ssn stream tcp nowait root /usr/sbin/smbd smbd
  netbios-ns dgram udp wait root /usr/sbin/nmbd nmbd
  ______________________________________________________________________

  Aȉ̃R}hs inetd X^[g܂B

  ______________________________________________________________________
      kill -HUP <pid of inetd>
  ______________________________________________________________________

  <pid of inetd> ɂ inetd ̃vZX ID ĂBps R}h
  ŊmF邩A"cat /var/run/inetd.pid" Ȃǂł킩܂B

  f[VXe̋NXNvgsꍇ́Aȉ̓e
  /etc/rc.d/init.d/smb Ƃč쐻AXNvg̃RgŎw肳
  t@Cւ̃V{bNNĂB

  ______________________________________________________________________
  #!/bin/sh

  #
  # /etc/rc.d/init.d/smb - starts and stops SMB services.
  #
  # The following files should be synbolic links to this file:
  # symlinks: /etc/rc.d/rc1.d/K35smb  (Kills SMB services on shutdown)
  #           /etc/rc.d/rc3.d/S91smb  (Starts SMB services in multiuser mode)
  #           /etc/rc.d/rc6.d/K35smb  (Kills SMB services on reboot)
  #

  # Source function library.
  . /etc/rc.d/init.d/functions

  # Source networking configuration.
  . /etc/sysconfig/network

  # Check that networking is up.
  [ ${NETWORKING} = "no" ] && exit 0

  # See how we were called.
  case "$1" in
    start)
      echo -n "Starting SMB services: "
      daemon smbd -D
      daemon nmbd -D
      echo
      touch /var/lock/subsys/smb
      ;;
    stop)
      echo -n "Shutting down SMB services: "
      killproc smbd
      killproc nmbd
      rm -f /var/lock/subsys/smb
      echo ""
      ;;
    *)
      echo "Usage: smb {start|stop}"
      exit 1
  esac
  ______________________________________________________________________

  ======

  Slackware ̏ꍇ́A/etc/rc.d/rc.local Ɉȉ̂悤ȍsǉĂ
  Ηǂł傤B

  ______________________________________________________________________
  if [ -f /usr/sbin/nmbd ]; then
    echo "SAMBA servers"
    /usr/sbin/smbd -D
    /usr/sbin/nmbd -D
  fi
  ______________________________________________________________________

  ==󒍏I==

  5.  /etc/smb.conf ̐ݒ

  Linux ł Unix łASamba ̐ݒ /etc/smb.conf Ƃt@C
  ɂ܂Ƃ߂ċLĂ܂Bǂ̃VXe\[XJ邩A܂
  ɂǂ̂悤ȐȂȂǂ́Ãt@CŐݒ肵܂B

  ̐߂ɑ 2 ߂ł Linux ̃hCuv^ Windows }V
  L@ɂďqׂ܂B̐߂Ŏ smb.conf ́Ał邾ȒP
  ɂ̋@\悤ɏ̂ł̂ŁA܂œIȂ
  ƍlĂB

   smb.conf ̏ڍׂȂĂSzKv͂܂BdvȊTO
  ɂĂ͌̐߂ł炽߂Đ܂B

  smb.conf ̊eX̃ZNV́AZNVwb_i[global]A[homes]A
  [printers] jn܂܂B

  global ZNVł͑SẴZNVɋʂȕϐw肵܂B

  homes ZNVw肷ƁA[g[Ũ͎z[fBNg
  փANZXł悤ɂȂ܂B܂ Samba zXgł Linux }V
  ɃAJEgĂl Windows }VŐڑƁAނll
  ̃z[fBNg𗘗pł悤ɂȂ܂B̃T[rX𗘗p
  ɂ Linux }VɃAJEgĂȂ΂Ȃ܂B

  Ɏ smb.conf ̗ł́A[g[Ũz[fBNg
  ɃANZXA/tmp fBNgɏ݂ł悤ɂĂ
  BWindows [Uɂ̃\[Xɂ́ALinux ̃zXg[
  Jȃlbg[NɂȂ΂Ȃ܂BWindows ̃t@C}l[W
  GNXv[p΁ÃhCulbg[NhCuƂ
  Đڑł܂B

  ̈̕ȉ̐߂ł́Ã\[XL邽߂ smb.conf t@C
  ̏ɂĂqׂĂ܂BQlɂĂB

  ______________________________________________________________________
  ; /etc/smb.conf
  ;
  ; Make sure and restart the server after making changes to this file, ex:
  ; /etc/rc.d/init.d/smb stop
  ; /etc/rc.d/init.d/smb start
  [global]
  ; Uncomment this if you want a guest account
  ; guest account = nobody
     log file = /var/log/samba-log.%m
     lock directory = /var/lock/samba
     share modes = yes

  [homes]
     comment = Home Directories
     browseable = no
     read only = no
     create mode = 0750

  [tmp]
     comment = Temporary file space
     path = /tmp
     read only = no
     public = yes
  ______________________________________________________________________

  6.  Linux ̃hCu Windows }V狤L

  ɂȒP smb.conf 悤ɁALinux ̃hCu Windows
  ̃[UL̂͊ȒPłB Samba ̃VXeł͔ɑ
  ̍ڂJX^}CYł܂Bȉɂ܂B

  fBNg𐧌ȂɌJɂ́A̐߂ŋsmb.conf 
  tmp ZNV܂˂āA̃p[^ݒ肵܂B

  ______________________________________________________________________
  [public]
     comment = Public Stuff
     path = /home/public
     public = yes
     writable = yes
     printable = yes
  ______________________________________________________________________

  ̃fBNg̐ƕςāAǂݏo͂ł\ƂA
  ݂ staff O[ṽ[UɌɂ́Aȉ̂悤ɂ܂B

  ______________________________________________________________________
  [public]
     comment = Public Stuff
     path = /home/public
     public = yes
     writable = yes
     printable = no
     write list = @staff
  ______________________________________________________________________

  hCuLɊւ鑼̎@ɂẮASamba t̕ man y[W
  ĂB

  ======

  Win 95 ō쐬t@Cő啶̋ʂA{𐳂
  \邽߂ɂ́Aglobal ZNVɈȉ̃GgǉĂ
  ǂ悤łB

  ______________________________________________________________________
     mangle case = no
     case sensitive = no
     default case = upper
     preserve case = yes
     short preserve case = yes
  ______________________________________________________________________

  {𗘗pɂ́ARpC Makefile 

               -DKANJI=\"euc\"

  ȂǂƎw肷Kv܂B܂ 1.9.16p2 ́Asmb.conf 

  ______________________________________________________________________
     coding system = <R[hn>
  ______________________________________________________________________

  ̂悤Ɏw肷邱Ƃ\ɂȂA܂ CAP ƓɎg߂ "cap" 
  R[hnǉ܂B

  ȂR[hn unicode ɂĂƁA{ Windows 95  Samba ̃h
  CuڑꍇAVKtH_̍쐬łȂȂƂs
  邻łB

  ==󒍏I==

  7.  Windows ̃hCu Linux }VŋL

  Samba ̔zzpbP[Wɂ́AUnix }V̂߂ SMB NCAgvO
  ܂܂Ă܂B̃vO ftp ̂悤ȃR}hw̃C
  ^[tF[XĂ܂B̃vOg΁AWindows ̃T[o
  ƁA Linux ̃NCAgƂ̂ŁAt@Ĉ肪ł܂B

  ======

  2.0 ȏȂǂ̍ŋ߂̃J[lł smbfs Ƃt@CVXe
  ANT Ȃǂ̃lbg[NhCu𒼐ڃ}Egł悤łBڍ
  ́AJ[lfBNg Documentation/filesystems/smbfs.txt 
  B

  ==󒍏I==

  zXgłǂȋLT[rXpo邩𒲂ׂ邽߂ɂ́Aȉ̂
  ȃR}hs܂B

  ______________________________________________________________________
      /usr/sbin/smbclient -L host
  ______________________________________________________________________

  host ɂׂ͒zXg̖O܂B̃R}hsƁA
  T[rX̃Xg܂BT[rXƂ́AȂ̃zXgŗ
  płhCuv^̖OłB SMB T[oɉ炩̃ZL
  eBĂƃpX[h𕷂܂̂ŁAguest AJEg
  ̃pX[hÃzXgł̂Ȃ̌lAJEg̃pX[h
  ĉB

  s܂B

  ______________________________________________________________________
      smbclient -L zimmerman
  ______________________________________________________________________

  sʂ͈ȉ̂悤ɂȂł傤B

  ______________________________________________________________________
  Server time is Sat Aug 10 15:58:27 1996
  Timezone is UTC+10.0
  Password:
  Domain=[WORKGROUP] OS=[Windows NT 3.51] Server=[NT LAN Manager 3.51]

  Server=[ZIMMERMAN] User=[] Workgroup=[WORKGROUP] Domain=[]

          Sharename      Type      Comment
          ---------      ----      -------
          ADMIN$         Disk      Remote Admin
          public         Disk      Public
          C$             Disk      Default share
          IPC$           IPC       Remote IPC
          OReilly        Printer   OReilly
          print$         Disk      Printer Drivers

  This machine has a browse list:

          Server               Comment
          ---------            -------
          HOPPER               Samba 1.9.15p8
          KERNIGAN             Samba 1.9.15p8
          LOVELACE             Samba 1.9.15p8
          RITCHIE              Samba 1.9.15p8
          ZIMMERMAN
  ______________________________________________________________________

  uEYXgibrowse listj́Albg[N̑ SMB T[őL
  \[X̂łB

  NCAgƂėpɂ͈ȉ̂悤Ɏs܂B

  ______________________________________________________________________
      /usr/sbin/smbclient service <password>
  ______________________________________________________________________

  service ɂ̓zXgƋLw肵܂BzXg zimmerman ɂ
  public ƂOŌJĂfBNg𗘗p邽߂
  ́Aservice  \\zimmerman\public ƂȂ܂BVF̃vvg炱
  ̃R}h𗘗pꍇ́AobNXbVGXP[vȂƂ
  񂩂Aǎ̂悤ɓ͂Kv܂B

  ______________________________________________________________________
      /usr/sbin/smbclient \\\\zimmerman\\public mypasswd
  ______________________________________________________________________

  mypassword ɂ́AȂ pX[ĥ܂܏ĂB

  ======

  ȉ͏{lԊɂƊȒPȓ͕@łB

  ______________________________________________________________________
      /usr/sbin/smbclient '\\zimmerman\public' mypasswd
  ______________________________________________________________________

  ==󒍏I==

  ȉ̂悤 smbclient ̃vvgoĂ܂B

  ______________________________________________________________________
  Server time is Sat Aug 10 15:58:44 1996
  Timezone is UTC+10.0
  Domain=[WORKGROUP] OS=[Windows NT 3.51] Server=[NT LAN Manager 3.51]
  smb: \>
  ______________________________________________________________________

  h ƑłĂ΁Asmbclient ̃wv܂B

  ______________________________________________________________________
  smb: \> h
  ls             dir            lcd            cd             pwd
  get            mget           put            mput           rename
  more           mask           del            rm             mkdir
  md             rmdir          rd             prompt         recurse
  translate      lowercase      print          printmode      queue
  cancel         stat           quit           q              exit
  newer          archive        tar            blocksize      tarmode
  setmode        help           ?              !
  smb: \>
  ______________________________________________________________________

  ftp glȂAman y[W܂łȂ smbclient g悤
  ɂȂł傤B

  8.  Linux }Ṽv^ Windows }V痘p

  Linux ̃v^ Windows 痘pɂ́ALinux Ńv^
  Ɠ삷悤ɐݒ肳ĂKv܂BLinux ł̃v
  głĂ SMB ł̋L͊ȒPłB

  [Jv^̐ݒɂĂ Printing HOWTO ݂ĂB

  MҎg Windows NT ɐڑĂv^gĂ̂ŁA̐
  ɏĂ邱Ƃ͐΂ɐƂ͌܂BxɎ󂯂Ƃ߂Ă
  ĂB̓IȎgpoĂႢ܂A
  ǂ dwood@plugged.net.au ܂Œm点ĂB΂̏͂̓
  eł܂B

  smb.conf Ƀv^̐ݒ܂B

  ______________________________________________________________________
  [global]
     printing = bsd
     printcap name = /etc/printcap
     load printers = yes
     log file = /var/log/samba-log.%m
     lock directory = /var/lock/samba

  [printers]
     comment = All Printers
     security = server
     path = /var/spool/lpd/lp
     browseable = no
     printable = yes
     public = yes
     writable = no
     create mode = 0700

  [ljet]
     security = server
     path = /var/spool/lpd/lp
     printer name = lp
     writable = yes
     public = yes
     printable = yes
     print command = lpr -r -h -P %p %s
  ______________________________________________________________________

  v^̃ZNVɂ path ɂ́A/etc/printcap Őݒ肵Xv[
  fBNgƓfBNgw肵ĂB

  : Samba g Unix }Ṽv^ Windows NT }V狤L
  ۂɂ͖_܂B̂̈́ANT ͋L
  v^ȂƂ̂łB̖ɂ Samba
  zzpbP[W docs/WinNT.txt t@CQƂĉBpX[h
  ւ܂B͓̕t@CĂA炢炷邾
  ŉɂ͂Ȃ܂...

  ======

  ҂ Linux ɂȂĂ Epson MJ-700V2C  Samba ŌJ
  Windows 95 gĂ܂̂ŁA̐ݒeȉɋL܂B
  AJ̓vCx[gAhX̂lbg[NȂ̂ŁA{IɃZ
  LeB̂Ƃ͍lĂ܂B

  ܂ smb.conf łB

  ______________________________________________________________________
  [global]
          lock directory = /var/locks/samba

          workgroup = WORKGROUP
          browseable = yes
          allow hosts = 192.168.111.

          printing = bsd
          load printers = no
          printcap name = /etc/printcap

          password level = 8
          create mode = 0750

          mangle case = no
          case sensitive = no
          default case = upper
          preserve case = yes
          short preserve case = yes

  [lp]
          comment = MJ-700V2C
          printer name  = lp
          path = /var/tmp

          printable = yes
          writable = yes
          create mode = 0700
  ______________________________________________________________________

  /etc/printcap łB

  ______________________________________________________________________
  lp:\
          :lp=/dev/lp1:\
          :sd=/var/spool/lpd/lp:\
          :lf=/var/spool/lpd/lp/errs:\
          :if=/var/spool/lpd/lp/incat:\
          :mx#0:\
          :sh:\
          :sf:
  ______________________________________________________________________

  CvbgtB^ /var/spool/lpd/lp/incat łB

  ______________________________________________________________________
  #!/bin/sh
  /bin/cat
  exit 0
  ______________________________________________________________________

  Windows 95 ́Albg[NhCuI MJ-700V2C ̃hC
  oőIŃCXg[Kv܂B

  ==󒍏I==

  9.  Linux }V Windows ̃v^g

  Windows }Ṽv^L邽߂ɂ͈ȉ̍ƂKvłB

  1. /etc/printcap ɐGgKvŁA̓[JȃfBN
     g\ɏ̂łKv܂iXv[fBNg̐
     ȂǁjB

  2. /usr/bin/smbprint XNvgKvłB Samba ̃\[Xpb
     P[WɕtĂ܂ASamba ̃oCizzpbP[Wɂ͕tĂ
     Ȃ܂BŃIWiXĈڂ܂B

  3. ASCII t@C Postscript `ɕϊKvꍇɂ́A
     nenscript Ȃǂ Postscript Ro[^Kv܂B
     nenscript ͒ʏ /usr/bin ɃCXg[Ă܂B

  4. Samba 𗘗peՂɂĂ悤ȃtgGh~
     ΁AȉɋLȒP perl XNvgĉBASCIIA
     PostscriptAcreated Postscript 悤ɂȂĂ܂B

  ȉɋL̂́AWindows NT v^ɐڑꂽ HP 5MP v^𗘗p
  邽߂ /etc/printcap ւ̃GgłBꂼ̓e͈ȉ̒ʂ
  łB

     cm Rg

     lp o͂ɎgfoCX

     sd ̃v^̂߂̃Xv[fBNg

     af AJEgt@C

     mx ő̃t@CTCYi0 ɂΖɂȂ܂j

     if ͂ɗptB^i܂̓XNvgj

  ɏ񂪕KvȂAPrinting HOWTO  printcap  man y[Wĉ
  B

  ______________________________________________________________________
  # /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:
  ______________________________________________________________________

  Xv[fBNgƃAJEgt@C݂ĂA݉\
  邱ƂmFĂĉB܂ printcap  if sɁAȉɋL
  smbprint XNvgւ̐pXݒ肳Ă邱ƁA lp s /dev
  fBNgɂ鐳foCXݒ肳Ă邱ƂmFĉB

   smbprint łB͒ʏ /usr/bin ɒuĂA Samba 
   Andrew Tridgell {lɂďꂽ̂łiM҂̒mȂ Samba
  ̋҂ɂ炷݂܂jB Samba ̃\[Xpb
  P[WɓĂ܂AoCizz̏ꍇɂ͖m܂̂ŁA
  ȉɎX̂Ă܂B

  ȉɋLXNvg𒍈Ӑ[ĉB̓IWiC
  ̂ŁAg₷ȂĂƎv܂B

  ______________________________________________________________________
  #!/bin/sh -x

  # This script is an input filter for printcap printing on a unix machine. It
  # uses the smbclient program to print the file to the specified smb-based
  # server and service.
  # For example you could have a printcap entry like this
  #
  # smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
  #
  # which would create a unix printer called "smb" that will print via this
  # script. You will need to create the spool directory /usr/spool/smb with
  # appropriate permissions and ownerships for your system.

  # Set these to the server and service you wish to print to
  # In this example I have a WfWg PC called "lapland" that has a printer
  # exported called "printer" with no password.

  #
  # Script further altered by hamiltom@ecnz.co.nz (Michael Hamilton)
  # so that the server, service, and password can be read from
  # a /usr/var/spool/lpd/PRINTNAME/.config file.
  #
  # In order for this to work the /etc/printcap entry must include an
  # accounting file (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:
  #
  # The /usr/var/spool/lpd/PRINTNAME/.config file should contain:
  #   server=PC_SERVER
  #   service=PR_SHARENAME
  #   password="password"
  #
  # E.g.
  #   server=PAULS_PC
  #   service=CJET_371
  #   password=""

  #
  # Debugging log file, change to /dev/null if you like.
  #
  logfile=/tmp/smb-print.log
  # logfile=/dev/null

  #
  # The last parameter to the filter is the accounting file name.
  #
  spool_dir=/var/spool/lpd/lp
  config_file=$spool_dir/.config

  # Should read the following variables set in the config file:
  #   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

  (
  # NOTE You may wish to add the line `echo translate' if you want automatic
  # CR/LF translation when printing.
          echo translate
          echo "print -"
          cat
  ) | /usr/bin/smbclient "\\\\$server\\$service" $password -U $user -N -P >> $log
  file
  ______________________________________________________________________

  قƂǂ Linux pbP[Wɂ́AASCII  Postscript ɂ
  nenscript R}h܂܂Ă܂Bȉ perl XNvǵA
  smbprint gĈۂɁAVvȃC^[tF[X񋟂
  ̂łB

  ______________________________________________________________________
  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 g ASCII t@CƁAs͉sĂ܂
  ܂B̃XNvgł́A\ȌP̓rł͂ȂA󔒂ŉs
  悤ɂĂ܂B

  \[XR[h̃tH[}bgɂ nenscript pĂ܂BASCII t@C
   2 ig݂ɐ`Awb_itAt@CȂǁj܂B
  ̃XNvg𐗌`ɂāA̐`@p邱Ƃłł傤B

  Postscript ͂̕łɐ`Ă̂Ƃ݂ȂāÂ܂ܒʂ
  ɂȂĂ܂B

  ______________________________________________________________________
  #!/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
  # Purpose:  Takes files of various types as arguments and
  # processes them appropriately for piping to a Samba print script.
  #
  # Currently supported file types:
  #
  # ASCII      - ensures that lines longer than $line_length characters wrap on
  #              whitespace.
  # Postscript - Takes no action.
  # Code       - Formats in Postscript (using nenscript) to display
  #              properly (landscape, font, etc).
  #

  # Set the maximum allowable length for each line of ASCII text.
  $line_length = 76;

  # Set the path and name of the Samba print script
  $print_prog = "/usr/bin/smbprint";

  # Set the path and name to nenscript (the ASCII-->Postscript converter)
  $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;
  }
  # Pipe the array to smbprint
  open(PRINTER, "|$print_prog") || die "Can't open $print_prog: $!\n";
  foreach $line (@newlines) {
          print PRINTER $line;
  }
  # Send an extra linefeed in case a file has an incomplete last line.
  print PRINTER "\n";
  close(PRINTER);
  print "Completed\n";
  exit 0;

  # --------------------------------------------------- #
  #        Everything below here is a subroutine        #
  # --------------------------------------------------- #
  sub ParseCmdLine {
          # Parses the command line, finding out what file type the file is

          # Gets $arg and $file to be the arguments (if the exists)
          # 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;
          }

          # Defining the file type
          unless ($cmd) {
                  # We have no arguments

                  if ($file =~ /\.ps$/) {
                          $filetype = "ps";
                  } elsif ($file =~ /\.java$|\.c$|\.h$|\.pl$|\.sh$|\.csh$|\.m4$|\.inc$|\.html$|\.htm$/) {
                          $filetype = "code";
                  } else {
                          $filetype = "ASCII";
                  }

                  # Process $file for what type is it and return $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 {
          # Create an array of file lines, where each line is < the
          # number of characters specified, and wrapped only on whitespace

          # Get the number of characters to limit the line to.
          $limit = pop(@_);

          # DBG
          #print "Entering subroutine wrap\n";
          #print "The line length limit is $limit\n";

          # Read in the file, parse and put into an array.
          open(FILE, "<$file") || die "Can't open $file: $!\n";
          while(<FILE>) {
                  $line = $_;

                  # DBG
                  #print "The line is:\n$line\n";

                  # Wrap the line if it is over the limit.
                  while ( length($line) > $limit ) {

                          # DBG
                          #print "Wrapping...";

                          # Get the first $limit +1 characters.
                          $part = substr($line,0,$limit +1);

                          # DBG
                          #print "The partial line is:\n$part\n";

                          # Check to see if the last character is a space.
                          $last_char = substr($part,-1, 1);
                          if ( " " eq $last_char ) {
                              # If it is, print the rest.

                              # DBG
                              #print "The last character was a space\n";

                              substr($line,0,$limit + 1) = "";
                              substr($part,-1,1) = "";
                              push(@newlines,"$part\n");
                          } else {
                               # If it is not, find the last space in the
                               # sub-line and print up to there.

                              # DBG
                              #print "The last character was not a space\n";

                               # Remove the character past $limit
                               substr($part,-1,1) = "";
                               # Reverse the line to make it easy to find
                               # the last space.
                               $revpart = reverse($part);
                               $index = index($revpart," ");
                               if ( $index > 0 ) {
                                 substr($line,0,$limit-$index) = "";
                                 push(@newlines,substr($part,0,$limit-$index)
                                     . "\n");
                               } else {
                                 # There was no space in the line, so
                                 # print it up to $limit.
                                 substr($line,0,$limit) = "";
                                 push(@newlines,substr($part,0,$limit)
                                     . "\n");
                               }
                          }
                  }
                  push(@newlines,$line);
          }
          close(FILE);
  }

  sub codeformat {
          # Call subroutine wrap then filter through nenscript
          &wrap($line_length);

          # Pipe the results through nenscript to create a Postscript
          # file that adheres to some decent format for printing
          # source code (landscape, Courier font, line numbers).
          # Print this to a temporary file first.
          $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);

          # Read the temporary file back into an array so it can be
          # passed to the Samba print script.
          @newlines = ("");
          open(FILE, "<$tmpfile") || die "Can't open $file: $!\n";
          while(<FILE>) {
                  push(@newlines,$_);
          }
          close(FILE);
          system("rm $tmpfile");
  }

  sub createarray {
          # Create the array for postscript
          open(FILE, "<$file") || die "Can't open $file: $!\n";
          while(<FILE>) {
                  push(@newlines,$_);
          }
          close(FILE);
  }
  ______________________________________________________________________

  ======

  nenscrpt ͓{ʂ܂񂪁AJE ɂ psconv Ƃ{ɑΉ
  R}hĂ܂Bɂ a2psAps2asciiA ps2txtAtoPS ȂǗlX
  Ȃ̂lbg[N\łB

  ȂA҂͂̏͂̃XNvgeXgł܂̂ŁA
  ɂXNvĝ܂܍ڂĂ܂Bē{ʂ
  ɐ́AA΍KłB

  ==󒍏I==

  10.  쌠

   HOWTO ̒쌠 1996 Nȍ~ David Wood ɂ̂Ƃ܂B
  ̐߂̐錾܂ނׂĂ̕ύXȂɂāA`
  ւ̂̕̕Aт̍Ĕzz܂B

  11.  ӎ

  [Ōӌ΁A̔ł̃[X̍ۂɁA̐߂ł
  OĊӂƎv܂B

  ======

  {ւ̖|ɓẮA

       {K ikko-@pacific.rim.or.jp
       K  juk@rccm.co.jp
       {i shom@i.h.kyoto-u.ac.jp
       Yj minoura@biol.s.u-tokyo.ac.jp

  Ɍ̎wELvȃRg܂B

  ==󒍏I==

