P. 1
Samba

Samba

|Views: 167|Likes:
Publicado porNurul Istiqomah

More info:

Published by: Nurul Istiqomah on Dec 14, 2010
Direitos Autorais:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

02/21/2014

pdf

text

original

This is the simplest possible pseudo printer. It does nothing but write a record to a log
file when its share is “printed to.”Start with this smb.confshare:

[pseudo]
print ok=yes
path=/home/username/test
print command=echo Pseudoprinter : %T >> test.log;rm %s

The print ok=yesline makes this a printer share. The path specifies that the file to be
printed,which has a variable substitution string of %s,is to be placed in the /home/

username/testdirectory. To trigger this share,from your Windows computer input the
following command:

C:\WINDOWS>echo hello > \\mainserv\pseudo

The preceding command “prints”the word “hello”(as a file) to “printer”

\\mainserv\pseudo. The bottom line in /home/username/test/test.loglooks like
this:

Pseudoprinter : 1999/10/30 16:52:18

Using Samba Server-Side Automation

CHAPTER14

419

14

U

S
I
N
G

S

A
M
B
A

S

E
R
V
E
R

-
S

I
D
E

A

U
T
O
M
A
T
I
O
N

17 8628 CH14 3/17/00 1:15 PM Page 419

Taking it one step further,you can record the word after echoin the DOS command. To
do so,change the print command=statement to this:

print command=echo Pseudoprinter : %T : $(head -n1 %s) >> test.log;rm %s

In the preceding command,%srepresents the file sent from DOS to be printed,and head

-n1 %sprints the first line of that file to stdout. Because that command is in parentheses
preceded by a dollar sign,its output is used as an argument to the echocommand. The
result is that if you execute the following three commands on the Windows client,you
see log output created by the pseudo printer share’s print command=parameter:

C:\WINDOWS>echo Samba > \\mainserv\pseudo
C:\WINDOWS>echo is > \\mainserv\pseudo
C:\WINDOWS>echo terrific > \\mainserv\pseudo

After executing the previous three commands on the Windows client,the last three lines
of test.loglook like this:

Pseudoprinter : 1999/10/30 18:53:38 : Samba
Pseudoprinter : 1999/10/30 18:53:45 : is
Pseudoprinter : 1999/10/30 18:53:52 : terrific

This is an introduction into using the contents of the print file as an input to the UNIX
program to be executed.

You're Reading a Free Preview

Descarregar
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->