Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- subprocess call's env passing
- #!/usr/bin/python
- import os, subprocess
- env = os.environ.copy()
- env['PASSWD'] = "hello jian"
- retcode = subprocess.call("smbclient -L //10.60.1.11 -U Mikejian"),env=env)
- print retcode
- def _validateSMBPassword(self, username, password):
- debug("call _validateSMBPassword %s:%s " % (username, password))
- import subprocess, os, shlex
- cmd = "sudo smbclient -L //%(server)s -U %(user)s"
- cmd = cmd % {
- 'server' : "10.60.1.11",
- 'user' : "Mikejian",
- }
- env = os.environ.copy()
- env['PASSWD'] = "hello jian"
- retcode = subprocess.call("smbclient -L //10.60.1.11 -U Mikejian",env=env,shell=True)
- debug("retcode:%d" % retcode)
- if retcode == 0:
- return True, True
- return False, False
- >>> smb = smbclient.SambaClient(server="MYSERVER", share="MYSHARE",
- ... username='foo', password='bar', domain='baz')
- ...
- >>> print smb.listdir("/")
- [u'file1.txt', u'file2.txt']
- >>> f = smb.open('/file1.txt')
- >>> data = f.read()
- >>> f.close()
- >>> smb.rename(u'/file1.txt', u'/file1.old')
Add Comment
Please, Sign In to add comment