1+ #Printouts and redirect the output to a log file of the details about the system.
2+
3+ import platform , os
4+ import datetime , time
5+
6+ #platform information
7+ plat = "Platform: " + platform .platform ()
8+
9+ a = platform .system () #platform type extract
10+
11+ if (a == "Linux" ): #check the platform type
12+
13+ #initialize , sort and print the system time and year
14+ x = datetime .datetime .now ()
15+ timeL = x .strftime ("%a %b %m %H:%M:%S" )
16+ timezone = time .strftime (str (time .timezone ))
17+ year = x .strftime ("%Y" )
18+
19+ path = os .path .expanduser ("~/Desktop/Entries_Lin.log" ) #path to the file
20+
21+ f1 = open (path , "w" ) #create a log file to write details
22+
23+ f1 .write (plat + "\n \n " + timeL + " " + timezone + " " + year + "\n \n " ) #write the platform date and time details in the log file
24+
25+ #access folders and subfolders in /usr/lib path -> write into the log file
26+ os .system ('find /usr/lib/ -name "*.bin" -type f >>' + path )
27+
28+ print ("Log file is created at: " + path )
29+
30+ elif (a == "Windows" ): #check the platform type
31+
32+ #initialize , sort and print the system time
33+ x = datetime .datetime .now ()
34+ timeW1 = x .strftime ("%d" "-" "%b" "-" "%y" )
35+ timeW2 = x .strftime ("%I" ":" "%M" " " "%p" )
36+
37+ path = os .path .expanduser ("~\Desktop\Entries_Win10.log" ) #path to the file
38+
39+ f2 = open (path , "w" ) #create a log file to write details
40+
41+ f2 .write (plat + "\n " + timeW1 + "\n " + timeW2 + "\n " ) #write the platform, date and time details in the log file
42+ f2 .close ()
43+
44+ #run the shell command for sort out .exe files and redirect them to the log file
45+ os .system ('dir C:\Windows\system32\*.exe >>' + path )
46+
47+ print ("Log file is created at: " + path )
0 commit comments