solaris

Error importing hashlib with python 2.7 but not with 2.6

Error importing hashlib with python 2.7 but not with 2.6 Question: I’m on Solaris 10 (x86). Until now, I was using python2.6. Today, I installed python2.7 and I have a weird error occuring when importing hashlib on 2.7, but not on 2.6: Python 2.6: root@myserver [PROD] # python2.6 -c “import hashlib” root@myserver [PROD] # Python …

Total answers: 4

error : NameError: name 'subprocess' is not defined

error : NameError: name 'subprocess' is not defined Question: #!/usr/bin/python3 username = ‘joe’ # generate passphrase pw_length = 6 phrase = subprocess.check_output([‘pwgen’, str(pw_length), ‘1’]) phrase = phrase.decode(‘utf-8’).strip() dev_null = open(‘/dev/null’, ‘w’) passwd = subprocess.Popen([‘sudo’, ‘passwd’, user], stdin=subprocess.PIPE, stdout=dev_null.fileno(), stderr=subprocess.STDOUT) passwd.communicate( ((phrase + ‘n’)*2).encode(‘utf-8’) ) if passwd.returncode != 0: raise OSError(‘password setting failed’) how do i …

Total answers: 1