Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pi_changehostname(oldname,newname):
- # hostname
- with fileinput.FileInput("/etc/hostname", inplace=True, backup='.bak') as file:
- for line in file:
- print(line.replace(oldname,newname), end='')
- if oldname in line:
- break
- # hosts
- with fileinput.FileInput("/etc/hosts", inplace=True, backup='.bak') as file:
- for line in file:
- print(line.replace(oldname,newname), end='')
- if oldname in line:
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement