How to change hostname in CentOS

Posted by cikul | Posted in Linux, Python | Posted on 11-01-2007-05-2008

3

CentOS was popular linux distribution which based on RedHat. All of Dutahost Server use CentOS for production server.

How to change hostname in CentOS and how to build Python script to handle this?
Read the rest of this entry »

Incoming search terms:

dhika | python set hostname | 

Change unix password with Python

Posted by cikul | Posted in Python | Posted on 11-01-2007-05-2008

2

Do you ever have problem while execute /usr/bin/passwd from your python code? actually i have problem with changing unix password from my python code.

First i try using pipe to control output from /usr/bin/passwd, hopefully i can send text with write() function.
this is the code :

#!/usr/bin/python
import os
COMMAND = 'passwd'
PASSWD  = 'mypassword'

# open a pipe to passwd program and
# write the data to the pipe
p = os.popen("%s" % COMMAND, 'w')
p.write(PASSWD)
p.write('n')
p.write(PASSWD)
p.close()

But i failed to change the password.

The solution is use Pexpect
Read the rest of this entry »