Source

# -*- coding: ascii"""sending smb network messagesauthor: Thomas Waldmannlicense: BSD"""fromsubprocessimportcheck_callascmdSENDMSG="""echo "%(msg)s" | smbclient -U%(user)s%%%(password)s -M %(hostname)s"""defsend_msg(msg,hostname,user=None,password=None,unattended=True):"""use smbclient to send a msg to hostname Note: do NOT give any user input to any parameter, it is unsafe. """ifunattended:# it seems like a dummy is OK, but if one does not give user and# password on the commandline, it will ask for it interactively:ifuserisNone:user="server"# it will say "message from <user> ..." in the popupifpasswordisNone:password=usercmd(SENDMSG%dict(msg=msg,hostname=hostname,user=user,password=password),shell=True)