Mendapatkan Info User (sederhana) Menggunakan Regex Pada Python

#!/usr/bin/python

import os, re

osenv = str(os.environ)
usrpat = re.compile(' 'USER': '(.*?)'')
homepat = re.compile(' 'HOME': '(.*?)'')

usrp = usrpat.findall(osenv)
hmrp = homepat.findall(osenv)

print 'USERNAME :' + usrp[0]
print 'HOME     :' + hmrp[0]

in action:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

About Hanny Haliwela

try to be or not try to be