SMB HOWTO
 David Wood, [email protected], ������� Alex Ott
 [email protected]
 v1.1, 25 ��� 1999

 ��� SMB HOWTO. ���� �������� �������� ������������ � Linux ��������
 Server Message Block (SMB), ������� ����� ���� �������� ����������
 Session Message Block (SMB), ���������� NetBIOS ��� ���������� LanMan�
 ager.
 ______________________________________________________________________

 Table of Contents


 1. ��������

 2. ������������� ���������

 3. �������

 4. ������ �������

 5. ������� ������� (/etc/smb.conf)

 6. ��������� ������ � ����� Linux ��� ���� ��� Windows

 7. ������ � ����� Windows �� Linux

 8. ������ � �������� Linux ��� Windows-����

 9. ������ � �������� Windows � ���� �������� ��� Linux

 10. Backing Up Windows Machines to a Linux Host

 11. ��������� ���

 12. �����������



 ______________________________________________________________________

 ������������������� ���������������������:: ����� ��� ���� ���������� � �������, ���
 ���������.



 11..  ����������������

 ��� SMB HOWTO. ���� �������� �������� ������������ � Linux ��������
 Server Message Block (SMB), ������� ����� ���� �������� ����������
 Session Message Block (SMB), ���������� NetBIOS ��� ����������
 LanManager. ���� ���� �������� � ���������� ��� Linux, �� Samba
 ����� ������ � ����������� Unix-�������� ����������� ������.

 ���� �������� ������������� David Wood ([email protected]).
 ���������, ��������� ��� ���������� ����� ���� ������ ��� ���
 �������� � �������� ������.

 ������� ���������� ����������� �� Samba �������� � WWW-�������
 Samba, ������� �������� �� ������ http://www.samba.org/
 <http://www.samba.org/>. �� ���� ������ ����������� ������ ��������
 comp.protocols.smb.

 �������� SMB ������������ Microsoft Windows 3.11, NT � 95/98 ���
 ��������� ������ � ����� � ��������. ��������� ���� ������ Samba
 �� Andrew Tridgell ([email protected]), UNIX-����� (�����
 Linux) ����� ������������ ������ � ����� � �������� ���
 Windows-����.  ������� smbfs �������� Paal-Kr. Engstad
 ([email protected]) � Volker Lendecke
 ([email protected]) ��� ����������� ����� � Unix ����������
 SMB-������� ��������� � ����� � Windows ��� Samba.

 ������ ����, ������� ����� ����� � ������ Samba:


 1. ���� ������ � ����� Linux Windows-�����.

 2. ������� ������ � ����� Windows ��� ���� ��� Linux.

 3. ���� ������ � �������� Linux ��� Windows-����.

 4. ������� ������ � �������� Windows �� Linux-������.

 ��� ���� ���� ����������� � ���� ���������.

 ���� �� ���������������: ��������� � �������� ���� ������ ���
 �����, ���� ���� ��������, ��� ��� ������ ��� ����, �������
 �������� ��. �������� ����������� ����� �� ������ � ����������
 ����� �����. ���� �� ����������� � ���� ��������, �� ������ ������
 ��������� ������ �������� � ���������� ��� ��� ���������, �� �����
 ������ �� ���������. ��� �� ������? �����, ����� ����� �������,
 ����������...

 �������, ��� ��� ������ � SMB-������� � ���� � Windows 3.x, � ���
 ������ ���� ��������� ���� TCP/IP � ���������� Win32s. �� ����
 ��������� �������� � ������ ����� Microsoft
 (http://www.microsoft.com <http://www.microsoft.com>).


 22..  ��������������������������� �������������������

 ���� �������� ����� ������� ��������� �� �������� �������� �������
 � ���������� SMB-�������  � Linux-�����. Samba �������� �����
 ������� � ���������� ������. ������ ������� ���������� ����� ��
 ���������� � Samba.

 ��� �������������� ��������� �������� �������� ���������:

 �  ����������� � Samba, �������� �� ���� ����������� Samba.
    ����������� �������� �� ������: ftp://ftp.samba.org/
    <ftp://ftp.samba.org/>

 �  The Linux Printing HOWTO.

 �  The Print2Win Mini-HOWTO.

 �  ������ �������� ��� ������ NetBIOS ��� ������������ ��������
    TCP/UDP.

    RRFFCC 11000011
       ��������� � ������.

    RRFFCC 11000022
       ��������� �����������



 33..  ����������������

 ����, ��� ���� ����� ����������� Samba �� ���� �����
 �������� � ��������� ethernet-�������� �������� ����, ���������
 �������� TCP/IP.  Samba �� ����� ������ ��������� ������ �������
 ���������. ��� � ����� �����, ��������� Linux � Windows 95/98/NT
 ���������� � ���������� TCP/IP. ����� ���� �� ����������� ����� �
 Windows 3.X, �� �� ���������� ������ ��������� TCP/IP.


 ������� SMB �� ����� ���� ����������� � �������� �������������.
 ���� �� ������ ������ ���-�� ��������, �� �� ���������� ��������
 ������� IP, ��� �� �������� ��������� ����������� ����� ��������.


 ��� ����, ����� �������� �������� ������ ��������� ������ Samba,
 ������� � ������� URL � �������� �������� � �� ������-������:
 ftp://ftp.samba.org/ <ftp://ftp.samba.org/>.

 �����, ���� � �� ��������� ����������� RedHat Linux, � �� �������
 ����������� ��������� �� �� ���� RedHat. ��������� ������
 ������������ ���� ������ ����������� ���� Samba.

 �������� �� ����� ���������� ��� ����� ���� Samba. ��� ������
 ������������ � /usr/sbin � ��������� ���� ��� ������� ��
 ��������� ��������, ���� ��  inetd.  ������� �������� ��� � ������
 ``������ �������''.


 ______________________________________________________________________
         smbd (����� SMB)
         nmbd (����������� ��������� ������ ���� NetBIOS ��� ��������)
 ______________________________________________________________________



 �������, ��� ������ ����, �������������� ������� nmbd ��������
 �������� �� ������ ����, ��������������� Domain Name Service (DNS).
 ������ ���� NetBIOS �������� �������� ���� � ����� Windows,
 ������������ ��� SMB. ������� ������, �������� ������ ���� DNS
 ������ �� ����� � ����������� Samba ��� ��������� ���� ����.

 ������ �������� �������� ���� Samba ������������ � ���������
 /usr/bin, ���� �� ����������� ����������.


 ______________________________________________________________________
         smbclient       (������ SMB ��� UNIX-����)
         smbprint        (������ ��� ����� � ������� � SMB-�����)
         smbprint.sysv   (���� �� ����, �� ��� ���� � SVR4 UNIX)
         smbstatus       (����������� ������� SMB-���������� ��� �������� �����)
         smbrun          ('glue' ������ ��� ����� ���������� � SMB-�����)
 ______________________________________________________________________



 �������� ���� ����������� � ��������� ������� ������� smbfs
 ���������� ���� � ���� ���������.

 ������������� � ���� ���������� ������ ������, ������� 'print',
 ������� ������ �� ������� �������� �� �������� smbprint.

 ���� Samba ����� ����� � ��������. ������ �������� �������� ������
 �� ������, �������� ����, � ��������� ��� README � ������������.
 ���� � ������������ ���� ��� �������� docs/INSTALL.txt, �������
 ��� ������� ���� �������� ����������.

 ��������� �������, �������� ������ � /usr/sbin � �������� ���� �
 /usr/bin. ��������� ��������� ������� � /usr/local/man.

 ��� �������� ���� Samba, �� ������ ����� � Makefile �����������
 ��� �����������, smb.conf. ������ ��� /etc, �� �� ������ ���������
 ��� ��� ������. ��� ���� ������, �� ����� ����������, ��� ��
 ����� ����������� ��� ����������� �� /etc/smb.conf,
 ����������� ��� �������� �� log file = /var/log/samba-log.%m �
 ������������� ���������� �� lock directory = /var/lock/samba.

 ��������� ��� ����������� smb.conf.  ��������� � ���������, ���
 ��� ������������ Samba.  ���������� � ������������� examples/simple
 � ��������� ��� README.  ���������� ��� smb.conf �������� � ����
 ���������� � ��������� /etc.  ���������� ����������������!! ���� � ��
 ����������� Linux � ��� ������������ Samba, � �� ��� ����� ���� ���
 ����������� Samba � /etc.  �������� �� ������ ���� ������ �
 ����-�� �� ���.

 ���� �� �� ������ ���������� ��� ����������� � ��������� /etc,
 �� ��������� ��� ��� �� ������, � ���� ��������� ������������
 ������ � ���� � ��������� /etc:


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




 44..  ������������ ��������������

 ���� �� ����� SMB /usr/sbin/smbd � /usr/sbin/nmbd.

 �� ������ �������� ������ Samba �� inetd ��� �� ���������� ��������.
 Samba ����� ������� ���� ������� ���� �� ������ �� ����������
 �������, ��� � ����� ���� �� ��������� �� inetd.

 � ��������� ������ �� ������ ��������� ������ � ���� /etc/services
 �������� ���� �����:



      ______________________________________________________________________
      netbios-ns      137/tcp         nbns
      netbios-ns      137/udp         nbns
      netbios-dgm     138/tcp         nbdgm
      netbios-dgm     138/udp         nbdgm
      netbios-ssn     139/tcp         nbssn
      ______________________________________________________________________




 ���������, ��� ��� ��� �� �������������. � ���������� �� �����
 �����������, �� ����� ��� ����� ����� ������� �� � ���� ���.
 Samba �� ������ ���������� � �������������� ����� ��� ���� �����
 �� ����� � ���� /etc/services.

 ��� ����� ������� �� inetd, ��������� �������� ������ �
 ��������������� ��� inetd, /etc/inetd.conf:








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




 ����� ������������ ����� inetd �������� ������:


 ______________________________________________________________________
     kill -HUP 1 `cat /var/run/inetd.pid`
 ______________________________________________________________________



 ��� ����� ������� �� ��������� �������� ��������, ���������
 �������� ������ � ��� /etc/rc.d/init.d/smb (��� ����������� RedHat)
 � ������� � ���� ������������� ������ � ������ �������� �
 �����������:












































 ______________________________________________________________________
     #!/bin/sh

     #
     # /etc/rc.d/init.d/smb - ������� � ���������� ������� SMB
     #
     # �������� ���� ������ ���� �������������� ������� � ���� ���:
     # symlinks:
     #           /etc/rc.d/rc1.d/K35smb  (������ ������� SMB ��� ���������
     #           /etc/rc.d/rc3.d/S91smb  (�������� ������� SMB � �������������������� ������)
     #           /etc/rc.d/rc6.d/K35smb  (������ ������� SMB ��� �����������)
     #

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




 ���� ��� ����� Samba �� �������� ��������� � ������� ���������, ���
 ����� �� ����� ���������� � ����� 139, �� �������� � �� ��� ����
 ��������� �������� Samba, ������� �� ���� ��������. ����������
 ������ ��������� (��������� ������ 'ps auxww | grep mbd') ��� ����,
 ����� ���������� ���� �� ��� ��������� ������� Samba.


 55..  ��������������� ���������������� ((//eettcc//ssmmbb..ccoonnff))

 ������� Samba � Linux (��� ������ UNIX-�����) ��������������
 ������������ �����, /etc/smb.conf. ���� ��� ���������� � ����
 ��������� ������� �� ������ ��� ������ ��� �������� ��� � ����
 ���������� �� ������ ��� � ������������ ���� ��������.

 �� �� �������� ������ ��������� ��������� ������ � ����� �
 �������� Linux ��� Windows-����, �� ��� smb.conf, �������� � ����
 ������ �������� ��������, ������������ � ����� ��������.


 �� ������������ ����� � ������. �������� ������ ������ ��������
 ���������.

 ����� ����� ��� �������� � ������� �����, ����� ��
 [global], [homes], [printers], � �.�..

 ������ [global] ���������� ��������� ����������, ������� Samba �����
 ����������� ��� ����������� ������ �� ���� �������.

 ����� [homes] ��������� �������� ������������ ����� ������ � �����
 (� ������ �����) ������� ����������� � �������� Linux-�����. ��
 ���, ���� ����������� Windows ��������� ����������� � ����� ������
 �� ����� Windows-����, �� ��� ����� ��������� � ����� �����������
 ������� �����������. �������, ��� ��� ���� ����� ������ ���, ���
 ������ ���� �������������� � Linux-�����.

 ������� ��� smb.conf, ����������� ����, ��������� ��������
 ������������ ����� ������ � �� ������� ����������� � ��������
 ����� � ����� �� �������� ���������. ��� ����, ����� �����������
 Windows ����� ������� ��� ������� ���� � Linux ����� ���� �
 �������� ����. ����� ����������� ������ �������� ������� ����� �
 ������ Windows File Manager ��� Windows Explorer.

 �������, ��� � �������� ������ ����� ��� �������������� ����� ���
 ����� ���, ����� ��� ������ � �������� ���������� ��������.



      ______________________________________________________________________
      ; /etc/smb.conf
      ;
      ; ��������� � ������������ ������ ����� �������� ��������� � ����
      ; ���, �������:
      ; /etc/rc.d/init.d/smb stop
      ; /etc/rc.d/init.d/smb start

      [global]
      ; ��������������� ��� ������, ���� �� ������ ��� ������ ���������� "�����"
      ; 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
      ______________________________________________________________________




 ����� ����� ��� smb.conf, ������� ��������� ��� �����������. ��
 ������ ��������� ����������� ������� ��� smb.conf, ���������
 ������� ���������� �������, �� smbd �������� ������� ��� �������.

 �������� ���: ���� �� ������ Samba ����� ������ ������ ethernet
 ���������, �� smbd ����� ���������� � ������������. ���� ��� ��,
 ��� �� ������ ���� ������ �� ���������� � ������� ������ ������ �
 ����� [global] ��� /etc/smb.conf:



      ______________________________________________________________________
      interfaces = 192.168.1.1/24
      ______________________________________________________________________




 ���� ���������� GUI-������ ��� �������� Samba: GtkSamba. ��������
 ������� �� ������ http://www.open-systems.com/gtksamba.html
 <http://www.open-systems.com/gtksamba.html>.



 66..  �������������������� ������������� �� ����������� LLiinnuuxx ������ ��������� ������ WWiinnddoowwss

 �� ������ ���� � ���� smb.conf, ��������� ������ � ����� Linux
 ��� ������������ Windows �������� �������� ������� �����. �����, �
 ������ Samba �� ������ ������������� ��� � ������� �������. ����� ��
 �������� ��������� ��������:

 ����� ���������� ������ ��� ����, ������� ���� ����� [tmp],
 ������������ ����, ������ ���-�� �������� � smb.conf:



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




 �� ����� ������ ����� ����������� �������� Samba � �����������
 ��������� ������� � Windows PC. �����, ������ Microsoft �����
 ����� ������� ����� ������� ��� ���, ��� ���������� Samba. Windows 98,
 Windows NT (service pack 3 ��� ����) � ������� ������ Windows 95
 ������ �� ������� ��������� ���������� �����. � Samba ��
 ������� ���������� ������������ �����. �� �� ������� �����������
 ���������� �������� ���� ���� ������ ���� ������ ���������
 ���������� �����, ������ ��� ���������� �� ����� ���� ������ ���
 ����������.

 ���� � �� ���� �������������� ����� ������ ����� �������� � ��������
 � ���� �� �������� ���������� � �������, �� �� ������ ������� ����
 ����� � ������� ����� ����� �������� ��������: "You are not
 authorized to access that account from this machine".

 �� ������ ���� �������� Samba-������ ��� ������������ ����������
 ������, ���� �������� ����� �  Windows, ����� ��� �����������
 ������������ �����.

 ��� ����, ����� ������� Windows ������ � ������������� �������
 SMB:

 Windows 95/98 =============


 ��������� ������� registry (regedit), ������� ��� registry
 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\VNETSUP
 ������� ������� ��� DWORD: ��� �������:  EnablePlainTextPassword
 �����:        0x01.

 Windows NT ==========

 ��������� ������� registry (regedit), ������� ��� registry
 HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Rdr\Parameters
 ������� ������� ��� DWORD: ��� �������:  EnablePlainTextPassword
 �������:        0x01

 ����� ����, �� �� ������ ��� ���������, ������������ ����� �
 Windows � ���������� ��������� ������� ���� � ������� Samba. ���
 ������ ������, ��������� ������ Samba ���������� ����� �
 ������������ ����.

 ��� ����, ����� �������� Samba ��� ������������ ���������� ������:

 � ����� [global] ��� /etc/smb.conf, ������� �������� ������:



      ______________________________________________________________________
      encrypt passwords = yes
      smb passwd file = /etc/smbpasswd
      ______________________________________________________________________




 �� �� ����������� ����������� �������� ���� ENCRYPTION.txt,
 Win95.txt � WinNT.txt � ����������� �� Samba �� ���� �� �� ������
 ����� ���!

 ���� ��� � ������� � ������ ��������� ���������� �����, �� �� ��
 ������� ����������� ������ ��������� �������� �� ��� ��� ���
 ������� ���������� �� ����� ������ � ���������� �������� ����.
 ��� ���� ����� ������ ������������ ����������, ������� ������ ���
 ������ � ��������� ���� Windows File Manager ��� Explorer, ���
 ������ ���� � ����� ���������� ��� ������ ������ ������ � ������.

 ���� �� �����������, ��� �� ������ ���� NetBIOS ���������� �������
 (�������� ������, ��� �� �������� ��������� �� ������ 'host not found
 (���� �� �����)' ��� ������� ����������), �� ����������
 ����������� IP-����� ������:  '\\<host ip address>\<sharename>'.

 ��� ����, ����� ���� ���������� ��������, �� ����� �����������
 ��������� ��������� �������� � �������������� ������ ������. ���
 ������ � �������� ��� ���������� 95/98/NT, �� ����� ����
 ���������� ����� �������� ��� ��������, ���� �� ����������� ��������
 � Windows 3.X:














 ______________________________________________________________________
     ; Mangle case = yes seems to give the correct filenames
     ; for Win95/98/NT.
     mangle case = yes

     ; If samba is case sensitive when looking for files
     case sensitive = no

     ; Default case of files that are created
     default case = lower

     ; Preserve case for all filenames
     preserve case = yes

     ; Preserve case for dos (8.3) filenames
     short preserve case = no
 ______________________________________________________________________




 ��������: ������� ����� ��� / ��� ����� � ������ ����. ���
 ���� ���� � ���� �������� ����� "24". ��� �������������� ���������
 � ��� �� ��������� ���������� ��� ��������, �� ������ ����������
 �������� �� ������
 http://www.ziplink.net/~ralphb/IPSubnet/index.html
 <http://www.ziplink.net/~ralphb/IPSubnet/index.html>.

 ������� ������� Samba ����� ����, ��� �� ������� �����, �� ��� ���
 �� ����������� ���� ������. ���� ��  ������ ������ ���-�� �����
 �������, �� � ��������� �� ������� � ������ Samba, ���������� ����.

 ����� ������ ��� ��������� ��������� ��� ������ �����, �� ��������
 ����� � ��� ������ ���� �� ������ staff, �������� ����� ��
 ������ � �������� �������:



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




 ��� ������� ������ ������� ��� ��������� ������ � �����, ��������
 ���������� � Samba � ��������� �������.


 77..  ������������ �� ����������� WWiinnddoowwss ���� LLiinnuuxx

 ������� ������ SMB ��� UNIX-���� ������ � ����������� Samba. ��
 ����������� ftp-�������� ��������� �������� ������. �� ������
 ����������� ��� ������� ��� ������� ����� ����� '��������' ���
 ���������� Windows � �������� ��� Linux.

 ��� ����, ����� ������� ���� ������� �������� � ����� �����,
 ��������� ������:


 ______________________________________________________________________
     /usr/sbin/smbclient -L host
 ______________________________________________________________________



 ��� 'host' ��� ��� �����, ������ �� ������ ������. �� �����
 ������ ������ ���� '��������' - �.�. ���� ������ ��� ��������� �
 ������� ����� ���� ������� ������. �� ��� ���, ��� SMB ������ ��
 ����� ������� ��� ��������� ��������, �� ����� �������� � ��
 �����. ������� � ����� � ����� ����� ��� ����������� '�����
 (guest)' ��� �� ����������� ����� � ���� �����.

 �������:


 ______________________________________________________________________
     smbclient -L zimmerman
 ______________________________________________________________________



 ����� ���� ������ ������ ��������� �������� ��:



      ______________________________________________________________________
      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
      ______________________________________________________________________




 Browse list �������� ������ SMB ������ � ���� � ����������
 ��������.

 ��� ������������ ������, ��������� ������� ������:




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



 ��� 'service' -- ��� ����� � ������. �������, ���� �� ��������
 ��������� � ����������, ������ ������� ��� ������ 'public' �
 ����� ������� 'zimmerman', �� ��� ������ ������ ������ ��
 \\zimmerman\public.  ����� � ��������� ���������� ��������, ��
 ���������� ������� ������� ����, �� ��� � ����� ��� �������
 ����� ��������� �������� ������:


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



 ��� 'mypasswd' -- ��������� ����� ����� �����.

 �� �������� ���������� smbclient:



      ______________________________________________________________________
      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' ����� �������� ������ �� ������������ smbclient:



      ______________________________________________________________________
      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, �� �� �� ����� ����� ���������
 ������� � smbclient.

 ���� �� ������ ����������� smbclient ��� �����������, �� �����
 ������� ����������� ��� � �����. ��� ����� �� ������ �����
 ���������� ���� smbfs. Smbfs ����������� � ����� ��������
 ��������, smbmount � smbumount. ��� ������ ������� mount � umount
 ��� SMB-��������.


 ���� smbfs ������ ������ � ����������� ������������� Linux. ���
 ���������� ������� ���� ���� ����: ��� ���� ����� ����������� ���
 ������� �� ��������� �������� smbfs � ����.


 88..  ������������ �� ���������������� LLiinnuuxx ������ WWiinnddoowwss--���������

 ��� ��������� ������ � Linux-�������� � Windows ����, ��
 ���������� ���������, ��� ������� ������ ��� Linux. ���� �� ������
 ������ ��� Linux, �� ��������� ������ � �������� ����� �����
 �����.

 �������� Printing HOWTO ��� �������������� ��������� � ��������
 �����.

 ��������� ����� ���������� �������, ����������� � ����� � Windows
 NT(��� ���� ���� - �� ������� ����� ���� ���� �������� � Linux),
 ���� ����� �� ������ ������������ �� ����������, � ������ ��
 �����������. � ���� ���� ��������� �� ��������� ����� ������,
 �������� �� ��� � �����: [email protected], �� ��� ���� �����
 ����� ���� �������� � �������.

 ������� �������� ������� � �� ��� smb.conf:



      ______________________________________________________________________
      [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
      ______________________________________________________________________




 ���������, ��� ���� � �������� (� ���� ����� ��� [ljet])
 ������������� �������� ����������, ������� � ���� /etc/printcap!

 ������:





 ______________________________________________________________________
    printcap name = /etc/printcap
    load printers = yes
 ______________________________________________________________________



 ����������� ������ �� ��� �������, ������������� � /etc/printcap ��
 ������� ���� ��������. ���� �� ������� ���, �� ��� ������� ���
 �������� ������ ������� � �����������. ����� [printers] �������
 �������� ��� ���������, ������� �� ������ ���������� ����. ����
 ����������� ��� ��������� ����� �� ������ ���� ������ (BSD), ��
 �� ���������� �������� �������� ��� printcap (��� �����������
 'print command', �������� ����). ��� �������������� ��������� �
 ������� printcap �������� Printing-HOWTO.

 �������� ������� ��� �������� ������� ���������� �������� ���������
 ������ ����� �:


 ______________________________________________________________________
    print command = cp %S /tmp/print.%P.%S
 ______________________________________________________________________



 �������� ��� ����� ���� ������������.

 �����������������: ��������� ��������� �������� � �������� � �������� �
 UNIX-����� ��� ���� � Windows NT ��������� Samba. ��� �� ������� �
 ���, ��� NT ���������� ����� ������� �������. ��� ������� ����
 ��������, �������� ������� � ���� docs/WinNT.txt �����������
 Samba. ����� ������� ����� � ��������� �����. ��������
 ���������� � ��� �� ���� ����.

 Oleg L. Machulskiy ([email protected]) ��������� ����� ������ ���
 ������������ ������ �����, ��� � ��������������� �������:



      ______________________________________________________________________
      print command = smb2ps %s | lpr -r -h -P %p
      ______________________________________________________________________




 ��� 'smb2ps' �������� ��������, ������� ���������� �������� ���,
 ��������� �� ��� Windows � ������ ������������ ��� Postscript. ��
 ������ ������ ������ ��� � ��������� ��� ������, ������ ��� ���
 ������ ������� ��������� ���� PJL ��� PCL.

 ���� ������ ����� ������ ���� �� ���� � Windows ������ PCL, �
 �� �������� Postscript. � ��������, ��� Windows 95/98/NT �� ����
 ������ ������ Postscript, �� ������ ������� "Digital turbo
 Printserver 20" ����� ������ �� ������� ������ Postscript ���
 ���������� ������. � ���� �����, ��� ��� ���� �� ����� �����
 ������ ������ "Apple LaserWriter II NTX".

 Jeff Stern ([email protected]) ����� ��������, ��� �����
 ������ ��������� �� ��:

 --------------------------%<----------------------------------

 � ���� ��� �������, ������ ������� � ���, ��� � ��� ������,
 ��������� lpd/lpr � ��� �������, ����������� � Linux, � ���� �����
 ��� Linux. �� � �� ��� ������ � ���� ������� � �������� ����� ���
 Win95. ���� � ��������� ��������

 smbclient \\eclectic\belen -P

 � ���� �������� ���������

 print myfile

 � ������� ��������� � ���, ��� ������ �������. � �������� ���
 ������ � ��������� /var/spool/lpd/lp1 ������ 777. � �������
 ��������, �� � ��� �����. � ���� ���������, � �������
 �����������, ��� � ��� �� ��������� ����, ��� ������������� �
 ����� � Linux � ������ 'lp', ��� ���� ��������� ���������� ������
 'users', � �.�... �� ����� ��� ������ (� ��������� root:lp).

 � �����, ����� ���� ������ ������ ���� ������������ ��� ���
 ����������� � ����� � Windows (������� ������� �����������
 ������� Linux ����� Samba), ������� ������ ���� ���� ����� � �
 ����� � Linux. ���� ������, ���� ����������� 'joe' � ����� �
 Windows, ������� 'mywinbox' ��������� ������� � ������� 'belen'
 � ����� � Linux 'eclectic' (\\eclectic\belen) �� ���� ������ ����
 ����������� 'joe' � ����� �  Linux. �����, ����� 'joe' ������ ����
 ������ ��� ������ � �������� 'belen' � ����� 'eclectic'. ���
 ����� ����� ������� ��� �������� ������� � ����� � Windows,
 ��������� ����� ��������� �������.

 � ����, ��� ��� �� ������ ���� ��������, ��������� � �������� ���
 ������� �� 'public' � smb.conf. �� ���������� �� ��� ���� ��������
 �����. (����� ��� Windows � ������� �� ��� �� �����������
 ����� ������ ��� ��� ��������� ������� (��� Linux). Windows ������
 ���������� ��� ��������� �����������, ������� �� �����, ����
 �������� Win95.

 --------------------------%<----------------------------------

 Dr. Michael Langner ([email protected] ����, ��� ������� ���
 ������ � ����� � ������ ���������� /var/spool/lpd/ ����� ����
 ��������, ������������� ����-�� ��������� "path=/tmp" � "print
 command = lpr -r -P%p %s".

 ����� �������� ����� ����� Postscript ��� ����� Postscript �
 ����� ��� Windows, ��� ������� ����� ������ ������ � ����� ������
 �����. ��������� ������ ����� ����� �������� ��������� "%%[
 Lastpage ]%%" � ��������. ��� ������ �������� ������ � ����� �
 Windows 95 � 98 � ��� ���������� ��-� ����, ��� Postscript ��������
 ������������������.

 ����� �� �������� �������� ���� ������ --- ����������� ������ ���
 ������� ���� ������� Postscript �� ����� �����. ������ ��������
 �������� ��������� ������� ������ Postscript ��� Windows. ��������
 ������ ������ ��� �� ��� ����������� LPRng ������ Postscript ���
 ����� � ������ Samba.

 Erik Ratcliffe ([email protected]), Caldera, �������, ��� ������������
 LPRng ������, ��� ���� ������ ������� ����� ���� ���������� �
 ���� ��� Windows. � ������� Samba, ��� ��������� ����� �
 /etc/printcap, ������ �������� �������� ��:








 ______________________________________________________________________
 raw:\
         :rw:sh:
         :lp=/dev/lp1
         :sd=/var/spool/lpd/raw
         :fx=flp
 ______________________________________________________________________




 LPRng �� ������� :\ � ����� ����� ������. ������ � �������� ��� ����
 ���������� ������ � ���� /etc/smb.conf ��� ����������� �������.
 ����� ������ ����� ���� ��� ������������ ����� "raw" �� ���
 /etc/printcap � ����� ������ ��������� � �������� �����. ����������
 ��� ��� ������� ������:



      ______________________________________________________________________
      print command = lpr -b -Praw %s
      ______________________________________________________________________




 ��� ���� ����� ����������� ��������� ��������� ����� �
 Windows95 ��� ����� ����� � �������, ������ ������������
 ���������� � �������.


 99..  ������������ �� ���������������� WWiinnddoowwss �� ��������� ������������������ ������ LLiinnuuxx

 ��� ������ � �������� � Windows �����, �� ������ ������ ��������:


 1. �� ������ ����� ��������� ����� � ���� /etc/printcap � ���
    ������ �������������� �������� ��������� ���������� (��� ��������
    ����������, � �.�.)

 2. � �� ������ ���� ������ /usr/bin/smbprint. �� ����������� ������
    � ��������� ������� Samba, �� �� �� ����� ��������� �������������
    Samba. ��� ������� �������������� ����� ���������� ����.

 3. ���� �� ������ ������������� ASCII ���� � Postscript, �� ������
    ����� �������� nenscript, ��� �� ���������.  nenscript -- ���
    ��������� Postscript, �� ������ ������������ � ���������
    /usr/bin.

 4. �� ������ ������� ������ ����� ����� Samba ����� ������,
    ��������� ��������-���������. ������� ������ � perl, �������
    ��������� ASCII, Postscript ��� ������������� Postscript
    �������� ����.

 5. �� ���� ������ ����������� MagicFilter ��� ����, ����� ���������,
    �������� ����. ����������� � �������� MagicFilter ����������
    ����. MagicFilter ����� �����������, ������, ��� �� ���� ��
    ������������ ������������� ��������� ������� ����������
    ������� �����.

 ������ � ���� /etc/printcap, ����������� ����, ����� ��� �������
 HP 5MP � ������� Windows NT. ����������� �������� ���� ���
 /etc/printcap:



 ______________________________________________________________________
         cm - ����������
         lp - ��� ���������, ����������� ��� �����
         sd - ���������� ���� ������� (� �������� �����)
         af - ��� ���� ���������� ���������
         mx - ���������� ����� ��� (���� -- ��� ����������)
         if - ��� �������� ������ (������)
 ______________________________________________________________________



 ��� ����� �������� ��������� � ����� �������� _P_r_i_n_t_i_n_g _H_O_W_T_O ���
 ��������� ������� �� 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:
      ______________________________________________________________________




 ���������, ��� �������� ���������� � ����������, ����������� ���
 ���� ���������� ��������� � ���� ���� � �����. ���������, ���
 ����� 'if' �������� ��������� ���� � ������� smbprint (�� ����) �
 ���������, ��� ����� ������� � ��������� ���������� �����
 (���������� ��� /dev).

 ���� ���� �� ������ smbprint. �� ������ �������� � ����������
 /usr/bin � ����� Andrew Tridgell, ���������, ������� ���� �����
 Samba, �������� � ���. ���� ������ ����������� ������ �
 ������������� ��������� ��� Samba, �� ����������� � ���������
 ������� ������������, �� ��� � �������� ��� �����.

 �� ������ ������� ��������� � ���� ����� ����������. ���� ���������
 ������ ���������, ������� ������ ���� ���������.



















 ______________________________________________________________________
 #!/bin/sh -x

 # ���� ������ �������� ������� �������� ��� ��������� � printcap
 # ����� � unix-�����. �� ���������� �������� smbclient ���
 # ����� ��� � ������� smb-������ � ������.
 # ������� �� ������ ����� ����� � printcap ������� ����
 #
 # smb:lp=/dev/null:sd=/usr/spool/smb:sh:if=/usr/local/samba/smbprint
 #
 # ������ ������ unix-������� ������� "smb", ������� �����
 # ������ � ������ ����� ������. ��� ���������� ������ ���������
 # ���� /usr/spool/smb � ��������������� ����� � ���������

 # ��������� ����� ������ � ������ � ������� �� ������ ������. �
 # ���� ������� � ��� PC � WfWg PC, ������ "lapland", ������
 # ����� �������������� �������, �������� "printer" ��� �����

 #
 # ���� ������ ��� ������� [email protected] (Michael Hamilton)
 # �� ��� ������, ������ � ����� ����� ���� ������ �� ���
 # /usr/var/spool/lpd/PRINTNAME/.config
 #
 # ��� ���� ����� ��� ������ ����� � /etc/printcap �����
 # ������ ��� ���� ������������ (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"
 #
 # �������,
 #   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 >> $logfile
 ______________________________________________________________________




 ����������� ������������� Linux ����������� � ��������� nenscript
 ��� ������������ ASCII ���������� � Postscript. �������� ������ �
 perl ����� ����� ����������� �����, ���������� ������� ���������
 ��� ����� ��������� smbprint.


 ______________________________________________________________________
 ������������: print [-a|c|p] <filename>
        -a ������ <filename> �� ASCII
        -c ������ <filename> ��������������� �� �������� ���
        -p ������ <filename> �� Postscript
         ���� ����� �� ����, ������� ��������� ����������
         ��� ��� � ������ ��������������
 ______________________________________________________________________



 ��������� smbprint ��� ����� ASCII �����, ������ ������ � ��������
 �������. ���� ��������, ���� ������ ������� ������ ������ �
 ������� (������ ����� � �������� ����).

 ������������ ��������� ��� ����������� � ������ ��������
 nenscript. �� ����� ASCII-��� � ���������� ��� � 2 ������� �
 ��������� (��, ��� ��� � �.�.). �� ������� ���� ��������
 ������. ��������� ���� ������ �� ������, ����� ���� �������� ������
 ���� ������������.

 Postscript-��������� ������� ��� �������������, �� ��� ���
 �������� ����.






















 ______________________________________________________________________
 #!/usr/bin/perl

 # ������:   print
 # ������:   Brad Marshall, David Wood
 #           Plugged In Communications
 # ��:   960808
 #
 # ������������ ��� ����� � ������ oreilly, ������� ��������� �
 # ������� zimmerman
 # ��������: ����� ���� ����� ����� �� �������� � ���������
 # �� �������������� ��� ������� � ������ ����� Samba.
 #
 # � �������� ����� ������������� ���� �����:
 #
 # ASCII      - ���� ���� ������ ������� ��� $line_length ��������, ��
 #              ��������� ������ � �������
 # Postscript - ����� ��� ��������
 # Code        - ���������� � Postscript (��������� nenscript), �����
 #               �������� �������� (��������� �����, ���� � �.�.)
 #

 # ��������� ��������� ����� ������ ASCII �����
 $line_length = 76;

 # ��������� ���� � ������� ����� Samba
 $print_prog = "/usr/bin/smbprint";

 # ��������� ���� � ��� nenscript (��������� ASCII-->Postscript)
 $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 "
 ������������: print [-a|c|p] <filename>
        -a ������ <filename> �� ASCII
        -c ������ <filename> ��������������� �� �������� ���
        -p ������ <filename> �� Postscript
         ���� ����� �� ����, ������� ��������� ����������
         ��� ��� � ������ ��������������\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);
 }
 ______________________________________________________________________





 ������ � ���������� MagicFilter. ������ Alberto Menegazzi
 ([email protected]) � ��� ��������.

 Alberto �������:
 --------------------------%<---------------------------------- 1)
 ��������� MagicFilter � /usr/bin/local � �������� ��� �����������
 ���������, �� �� ��������� ����� � /etc/printcap, �� ������������
 � ����������� � MagicFilter.

 2) �������� � /etc/printcap �������� ��� ��� ����� (��� ������ ���
 ����� ������� LaserJet 4L):

 lp|ljet4l:\ :cm=HP LaserJet 4L:\ :lp=/dev/null:\
 # or /dev/lp1 :sd=/var/spool/lpd/ljet4l:\
 :af=/var/spool/lpd/ljet4l/acct:\ :sh:mx#0:\ :if=/usr/local/bin/main-
 filter:

 �� ������, ���������, ��� ���������� lp=/dev/... ���������� ���
 �����������, �� ��� ��� ������ ��������� ������� ������������
 ���� "���������� ����������".


 ������ ������� : touch /dev/ljet4l

 3) ������� ������ /usr/local/bin/main-filter, � ���� �� ������
 ��������� ������������ ljet4l-filter ������ cat.

 ��� �� ��� ����.

 #! /bin/sh logfile=/var/log/smb-print.log
 spool_dir=/var/spool/lpd/ljet4l ( echo "print -"
 /usr/local/bin/ljet4l-filter ) | /usr/bin/smbclient "\\\\SHIR\\HPLJ4"
 -N -P >> $logfile

 P.S. : ��� ���� �� Print2Win mini-Howto � ����������� � ����
 ������� ���������� �������

 ---���� ����� --------- ����� �� Rick Bressler :

 Good tip sheet.  I use something very similar.  One helpful tip, this
 is not a particularly good idea:

 :lp=/dev/null:\

 lpr does an 'exclusive' open on the file you specify as lp=.  It does
 this in order to prevent multiple processes from trying to print to
 the dame printer at the same time.

 The side effect of this is that in your case, eng and colour can't
 print at the same time, (usually more or less transparent since they
 probably print quickly and since they queue you probably don't notice)
 but any other process that tries to write to /dev/null will break!

 On a single user system, probably not a big problem.  I have a system
 with over 50 printers.  It would be a problem there.

 The solution is to create a dummy printer for each.  Eg: touch
 /dev/eng.

 I have modified the lp entries in the printcap file above to take into
 account Rick's suggestion. I did the following:


 #touch /dev/eng #touch /dev/colour

 ---Ends here

 --------------------------%<----------------------------------



 1100..  BBaacckkiinngg UUpp WWiinnddoowwss MMaacchhiinneess ttoo aa LLiinnuuxx HHoosstt

 Adam Neat ([email protected]) kindly contributed the following
 script to back up Windows machines to a Linux host, using the
 smbclient utility.  Adam says that it is used to backup Windows 3.x
 and NT machines to a Linux based DAT SCSI Drive.

 Adam is not proud of the coding style used here, but it works.  As I
 like to say, "If it works and its stupid, then it is not stupid".

 In this script, the string 'agnea1' is the username on the Linux
 machine that does the backups.





 ______________________________________________________________________
 #!/bin/bash

 clear
 echo Initialising ...
 checkdate=`date | awk '{print $1}'`

 if [ -f "~agnea1/backup-dir/backup-data" ]; then

         echo "ERROR: No config file for today!"
         echo "FATAL!"
         exit 1
 fi

 if [ -d "~agnea1/backup-dir/temp" ]; then

         echo "ERROR: No tempoary directory found!"
         echo
         echo "Attempting to create"
         cd ~agnea1
         cd backup-dir
         mkdir temp
         echo "Directory Made - temp"
 fi

 if [ "$1" = "" ]; then

         echo "ERROR: enter in a machine name (ie: cdwriter)"
         exit 1
 fi

 if [ "$2" = "" ]; then

         echo "ERROR: enter in a SMB (Lan Manager) Resource (ie: work)"
         exit 1
 fi

 if [ "$3" = "" ]; then

         echo "ERROR: enter in an IP address for $1 (ie:
         130.xxx.xxx.52)" exit 1
 fi


 #############################################################################
 # Main Section
 #
 #############################################################################

 cd ~agnea1/backup-dir/temp
 rm -r ~agnea1/backup-dir/temp/*
 cd ~agnea1/backup-dir/

 case "$checkdate"
 in
         Mon)
                 echo "Backuping for Monday"
                 cat backup-data | /usr/local/samba/bin/smbclient
                 \\\\$1\\$2 -I$3 -N echo "Complete"

                         if [ -d "~agnea1/backup-dir/Monday" ]; then
                                 echo "Directory Monday Not found ...
                                 making" mkdir
                                 ~agnea1/backup-dir/Monday
                         fi

                 echo "Archiving ..."
                 cd ~agnea1/backup-dir/temp
                 tar -cf monday.tar *                echo "done ..."
                 rm ~agnea1/backup-dir/Monday/monday.tar
                 mv monday.tar ~agnea1/backup-dir/Monday
                 ;;


         Tue)
                 echo "Backuping for Tuesday"
                 cat backup-data | /usr/local/samba/bin/smbclient
                 \\\\$1\\$2 -I$3 -N echo "Complete"

                         if [ -d "~agnea1/backup-dir/Tuesday" ]; then
                                 echo "Directory Tuesday Not found ...
                                 making" mkdir
                                 ~agnea1/backup-dir/Tuesday
                         fi
                 echo "Archiving ..."
                 cd ~agnea1/backup-dir/temp
                 tar -cf tuesday.tar *
                 echo "done ..."
                 rm ~agnea1/backup-dir/Tuesday/tuesday.tar
                 mv tuesday.tar ~agnea1/backup-dir/Tuesday
                 ;;

         Wed)
                 echo "Backuping for Wednesday"
                 cat backup-data | /usr/local/samba/bin/smbclient
                 \\\\$1\\$2 -I$3 -N echo "Complete"

                         if [ -d "~agnea1/backup-dir/Wednesday" ]; then
                                 echo "Directory Wednesday Not found
                                 ... making" mkdir
                                 ~agnea1/backup-dir/Wednesday
                         fi
                 echo "Archiving ..."
                 cd ~agnea1/backup-dir/temp
                 tar -cf wednesday.tar *
                 echo "done ..."
              rm ~agnea1/backup-dir/Wednesday/wednesday.tar
                 mv wednesday.tar ~agnea1/backup-dir/Wednesday
                 ;;

         Thu)
                 echo "Backuping for Thrusday"
                 cat backup-data | /usr/local/samba/bin/smbclient
                 \\\\$1\\$2 -I$3 -N echo "Complete"

                         if [ -d "~agnea1/backup-dir/Thursday" ]; then
                                 echo "Directory Thrusday Not found ...
                                 making" mkdir
                                 ~agnea1/backup-dir/Thursday
                         fi
                 echo "Archiving ..."
                 cd ~agnea1/backup-dir/temp
                 tar -cf thursday.tar *
                 echo "done ..."
                 rm ~agnea1/backup-dir/Thursday/thursday.tar
                 mv thursday.tar ~agnea1/backup-dir/Thursday
                 ;;


         Fri)
                 echo "Backuping for Friday"
                 cat backup-data | /usr/local/samba/bin/smbclient
                 \\\\$1\\$2 -I$3 -N echo "Complete"

                         if [ -d "~agnea1/backup-dir/Friday" ]; then
                                 echo "Directory Friday Not found ...
                                 making" mkdir
                                 ~agnea1/backup-dir/Friday
                         fi
                 echo "Archiving ..."
                 cd ~agnea1/backup-dir/temp
                 tar -cf friday.tar *
                 echo "done ..."
                 rm ~agnea1/backup-dir/Friday/friday.tar
                 mv friday.tar ~agnea1/backup-dir/Friday
                 ;;

         *)
                 echo "FATAL ERROR: Unknown variable passed for day"
                 exit 1;;

 esac
 ###########
 ______________________________________________________________________






 1111..  ������������������ ��������

 ���������� ����� � ���� �������� ������ David Wood, 1996-9. ��
 ����� ��������������� � ���� ����� � �������� ��������������, ���
 ��������� ��� ����������, ����� ��� ��������.


 1122..  ������������������������

 Brad Marshall ([email protected]) � Jason Parker
 ([email protected]) ������� �����, ���������� ������������,
 �������� ������ � ����������� ������������.


 Adam Neat ([email protected]) �������������� ������ ��� ���������
 ����� � ����� ��� Windows � ����� � Linux.


 Matthew Flint ([email protected]) ���������� ��� ��
 ������������ �������� 'interfaces' � ���� smb.conf.


 Oleg L. Machulskiy ([email protected]), Jeff Stern
 ([email protected]), Dr. Michael Langner (langner@fiz-
 chemie.de and Erik Ratcliffe ([email protected]) ������������ ���������
 � ����� �� ��������� ������ � �������� Linux ��� ���� � Windows.


 Alberto Menegazzi ([email protected]) �������������� ��� ��������
 ��� MagicFilter, ����� �� ���� ����������� ������ � �������� Windows
 ��� ���� � Linux.

 Andrea Girotto ([email protected]) ��������� ��� ���������
 ���������� �������� ������������ ������ ��������.


 ���� ������ ���� ���������� ������������, ������� ��������� ����
 �������� � ��� �� ��������� �� ���������: Takeo Nakano
 ([email protected]), Klaus-Dieter Schumacher (Klaus-
 [email protected]), Andrea Girotto
 ([email protected]) � ������ ������. � ������� � �� ���
 ��������� ���������.