Usertime

Script to help with tracking time of users logged into system.


In [11]:
import os
import getpass

In [ ]:


In [5]:
getusr = getpass.getuser()

In [6]:
getusr


Out[6]:
'wcmckee'

In [7]:
hostndir = ('/home/' + getusr + '/sellcoffee/hostnames/')

In [12]:
hostndir


Out[12]:
'/home/wcmckee/sellcoffee/hostnames/'

In [13]:
chosd = os.chdir(hostndir)

In [14]:
chosd

In [ ]:


In [15]:
os.system('hostname > host.txt')

rdhos = open('host.txt', 'r')

rdtxt = rdhos.read()

rdhos.close()

rdstp = rdtxt.strip('\n')

In [16]:
rdstp


Out[16]:
'localhost'

In [17]:
os.system('users > ' + rdstp)


Out[17]:
0

In [19]:
os.system('rm -rf host.txt')


Out[19]:
0

In [20]:
print ('script success')


script success

In [ ]: