-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (140 loc) · 4.77 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/usr/bin/env python
import os
import getpass #To take inputs from user invisiblly not in echo back .
os.system("tput setab 17")
os.system('tput setaf 1')
print('\t\t\t***** Hey to my TUI that makes life simple *****')
os.system('tput setaf 7')
print("\n\n")
os.system("tput setaf 5")
print('\t\t.......................................................\n')
print('\t\t\t***********************************\n')
print('\t\t.......................................................\n')
os.system("tput setaf 9")
print('\n\n')
os.system("tput setaf 3")
print("""\t\t|^^^^^) !---- \ / ^^^^!^^^^ ! ! -!-
| | |____ \ / ! ! ! !
| | ! \ / ! ! ! !
| ) !____ \/ ________ ! !*****! -!-
^^^^^
""")
os.system("tput setaf 9")
# To give Authentication to this TUI project.
def my_passwd(password="tui369"):
return password
passwd = getpass.getpass("Enter Password : ")
dpass = my_passwd()
apass = dpass
if passwd != apass :
os.system("tput setaf 1")
print("!!! Authentication is Incorrect !!!")
exit()
print("\n\n")
print("Where you want to perform your job (local/remote) : " , end='')
location=input()
print("location")
if location == "remote" :
remoteIP = input("Enter user IP : ")
os.system("ping {0}".format(remoteIP))
while True:
os.system("tput setaf 6")
print("""
Press 1 : To see Date
Press 2 : To check Cal
Press 3 : To conf web server
Press 4 : To create user
Press 5 : To create file
Press 6 : To reboot or shutdown pc
Press 7 : To update or upgrade
Press 8 : To install a software
Press 9 : To run a program
Press 10: To read manual
Press 11: To run a CLI program/code on different CLI i.e. tty
Press 12: To chane authentication password
Press 13: To Exit
""")
print("Enter your choice : " , end="")
ch=input()
print(ch)
os.system("tput setaf 10")
if location == "local" :
if int(ch) == 1 :
os.system("date")
elif int(ch) == 2 :
os.system('cal')
elif int(ch) == 3 :
os.system('sudo apt install httpd')
elif int(ch) == 4 :
print('Can you plz username : ' , end='')
create_user = input()
os.system('sudo useradd {0}'.foramt(create_user))
elif int(ch) == 5 :
print('Create new file you want : ' , end='')
create_file=input()
os.system('touch {} '.format(create_file))
elif int(ch) == 6 :
rbt_sdn=input("Enter 'reboot' for rebooting or for 'shutdown' for shutdown your pc : ")
os.system('{} '.format(rbt_sdn))
elif int(ch) == 7 :
print("Enter 'update' for updating or 'upgrade' for upgrading " , end='')
ud_ug=input()
os.system('sudo apt {} '.format(ud_ug))
elif int(ch) == 8 :
print("Which software you want to install :" , end='')
install = input()
os.system('sudo apt install {0}'.format(install))
elif int(ch) == 9 :
os.system('tput setab 90')
os.system('tput setaf 108')
print("Which program you want to run : " , end='')
program = input()
os.system("{0}".format(program))
elif int(ch) ==10 :
manual=input("Enter the manual you want to read : ")
os.system("man {} ".format(manual))
elif int(ch) ==11 :
os.system("tput setaf 3")
print("Your curent tty location !!!")
os.system("tty")
tty_n=input("Enter virtual terminal number 0-7 : ")
os.system("chvt {}".format(tty_n))
pgm=input("Enter a program you want to run : ")
cli=input("Give destination on which you want to run program : ")
os.system("{0} > {1} ".format(pgm , cli))
#To change authentication password.
elif int(ch) ==12 :
print('Enter new password : ')
dpass = my_func(getpass.getpass())
apass = dpass
check_pass = getpass.getpass("Check new password : ")
if check_pass != apass :
os.system("tput setaf 1")
print("!!! Check password is not matching !!!")
check_pass = getpass.getpass("Enter matched password with new password : ")
if check_pass == apass :
os.system('tput setaf 5')
print("!!! Your Authentication Password has been successfully changed !!!")
else:
os.system("tput setaf 5")
print("!!! Your Authentication Password has been successfully changed !!!")
elif int(ch) ==13 :
exit()
else:
os.system('tput setaf 1')
print('Option Not Supported ! Please choose a valid option.')
"""
elif location == "remote" :
if int(ch) == 1 :
os.system("ssh {0} date".format(remoteIP))
elif int(ch) == 2 :
os.system("ssh {0} cal".format(remoteIP))
elif int(ch) == 3 :
os.system("ssh {0} sudo apt install httpd".format(remoteIP))
elif int(ch) == 4 :
print("Can you plz username : ")
create_user = input()
os.system("ssh {0} sudo useradd {1}".format(remoteIP , create_user))
else:
print("Option Not Supported")
"""