-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic_linux_cmd_and_webserver_configuration
52 lines (51 loc) · 1.78 KB
/
basic_linux_cmd_and_webserver_configuration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import subprocess as sp
import os
print("\t--------------------WELCOME USER--------------")
ch = 'Y'
while ch == 'Y':
print("\tCHOOSE ANY OF THE BELOW OPTION:")
print("\tPress 1 : To run Linux basic commands")
print("\tPress 2 : To configure webserver")
base = input("\tEnter your choice: ")
if base=="1":
print("PLEASE ENTER ONE OF THE FOLLOWING COMMAND TO RUN:")
print("""1 : cal
2 : date
3 : ls""")
x = input()
if x=="1":
res = input("\tWould you like to see calendar of particular date?[Y/N]")
if res == 'Y':
print("\tPlease type date to see")
date = input()
op = sp.getoutput("cal {}".format(date))
print(op)
else:
output = sp.getoutput("cal")
print(output)
elif x=="2":
output = sp.getoutput("date")
print(output)
elif x=="3":
output = sp.getoutput("ls")
detail = input("\tWould you like to see detailed info of all content?[Y/N]")
if detail == 'Y':
op2 = sp.getoutput("ls -l")
print(op2)
else:
print(output)
elif base == "2":
output = sp.getoutput("yum install httpd -y")
print(output)
print("\tAPACHE WEBSERVER IS SUCCESSFULLY INSTALLED")
webpage=input("\tENTER WEBPAGE NAME: ")
print("\tin progress....")
content = input("\tENTER CONTENT: ")
savefile = open(webpage,'w')
savefile.write(content)
savefile.close()
op2 = sp.getoutput("mv {} /var/www/html/".format(webpage))
output = sp.getoutput("systemctl start httpd")
else:
print("INVALID INPUT")
ch = input("WOULD YOU LIKE TO CONTINUE?[Y/N]")