⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smb-howto.txt

📁 linux-bible.rar linux-bible.rar
💻 TXT
📖 第 1 页 / 共 3 页
字号:
        echo "print -"        cat) | /usr/bin/smbclient "\\\\$server\\$service" $password -U $user -N -P >> $logfile       ______________________________________________________________        大部分 linux 发行套件随附 nenscript 其用来转换 ASCII 文件成   Postscript. 以下 perl script 经由 smbprint 使更容易提供一种简单介面给   linux 的列印.     _________________________________________________________________   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 来列印 ASCII 档案便於截断过长的行. 如果可能的话,这个   script 截断长行於空白键处(取代在字的中间).      格式化过的原始码是被 nenscript 处理过. 它处理 ASCII 档而且用个特选的标   头(像 date,filename等)格式化成两栏. 它也可计算行数. 使用这当作例子, 其   他格式型态可以达成的.      Postscript 文件已经适当地格式化了,所以它们直接通过.       ______________________________________________________________     #!/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);# DBGprint "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 smbprintopen(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);}       ______________________________________________________________     10. 版权   1996 年的 HOWTO 版权是属於 David Wood. 它可以用任何型式的再重覆产生以及   自由的散播,只要这个档原封不动,包含这段叙述.   11. 感激   只要你写信给我提供意见, 我将会在这(文件)的下一版感激你.References   1. mailto:dwood@plugged.net.au   2. mailto:r6921068@ms.cc.ntu.edu.tw   3. mailto:dwood@plugged.net.au   4. ftp://nimbus.anu.edu.au/pub/tridge/samba/   5. ftp://nimbus.anu.edu.au/pub/tridge/samba/   6. file://localhost/tmp/bg5sgmltools.30848/SMB-HOWTO.txt.html#sec-daemons   7. mailto:dwood@plugged.net.au

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -