Welcome, guest | Sign In | My Account | Store | Cart

script to retrieve time, current user, and root of directory output to spam.txt

want to add more like windows version, bios info and other useful diagnostic information

free to use and modify welcome any advice or corrections learning python hope this turns into a script to create a organized personal report of customer's pc

Python, 18 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#! usr/bin/python

import dircache
import getpass
import time

logfile = open("spam.txt", "w+")

localtime = time.asctime( time.localtime(time.time()) )
print >> logfile, 'local current time :', localtime

usr = getpass.getuser()
print >> logfile, 'current user :' + usr

lst = dircache.listdir('/')
print >> logfile, lst

logfile.close()

1 comment

Kirankumar N 9 years, 11 months ago  # | flag

Hi,

i need a similar script which will create a user in linux machine and if the user already exists should throw an exception, stuck with the same pls help me out,