/
bcast-winpopup
executable file
·42 lines (36 loc) · 1.08 KB
/
bcast-winpopup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/python2.2
import os, re, sys
def getsmbmachines():
starting = 0
retval = {}
fd = os.popen("smbstatus -S")
for line in fd.xreadlines():
line = line.strip()
if not len(line):
continue
if not starting:
if line.startswith('-----'):
starting = 1
continue
service, uid, gid, pid, machine = \
re.search('^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)', line).groups()
retval[machine] = 1
return retval.keys()
print "Reading message (if at keyboard, type it, then hit Ctrl-D).."
message = sys.stdin.read()
print len(message)
message = message.strip()
message = re.sub("\n", "", message)
sys.stdout.write("Getting a list of machines... ")
sys.stdout.flush()
machines = getsmbmachines()
machines.sort()
transmitted = 0
count = len(machines)
print count
for machine in ['transfax2']:
transmitted += 1
print "Sending message %-3d of %-3d to %s" % (transmitted, count, machine)
fd = os.popen("smbclient -M %s" % machine, "w")
fd.write(message)
fd.close()