-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfile.py
More file actions
57 lines (54 loc) · 1.79 KB
/
file.py
File metadata and controls
57 lines (54 loc) · 1.79 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
import os
import subprocess
def createFile():
print("Enter File Name: ", end=' ')
FileName = input()
y = subprocess.getstatusoutput("cat {}".format(FileName))
x = subprocess.getstatusoutput("touch {}".format(FileName))
if y[0] == 0:
os.system('tput setaf 1')
print ("File of this name already exits. Try a different name")
os.system('tput setaf 7')
else:
os.system('tput setaf 2')
print ("File Successfully Created")
os.system('tput setaf 7')
def createRemoteFile(remotehost):
print("Enter File Name: ", end=' ')
FileName = input()
y = subprocess.getstatusoutput("ssh {} cat {}".format(remotehost, FileName))
x = subprocess.getstatusoutput("ssh {} touch {}".format(remotehost, FileName))
if y[0] == 0:
os.system('tput setaf 1')
print ("File of this name already exits. Try a different name")
os.system('tput setaf 7')
else:
os.system('tput setaf 2')
print ("File Successfully Created")
os.system('tput setaf 7')
def deleteFile():
print("Enter File Name: ", end=' ')
FileName = input()
y = subprocess.getstatusoutput("cat {}".format(FileName))
if y[0] == 0:
os.system('tput setaf 2')
os.system("rm {}".format(FileName))
print ("'{}' Deleted Sucessfully".format(FileName))
os.system('tput setaf 7')
else:
os.system('tput setaf 1')
print ("File '{}' Does Not Exists".format(FileName))
os.system('tput setaf 7')
def deleteRemoteFile(remotehost):
print("Enter File Name: ", end=' ')
FileName = input()
y = subprocess.getstatusoutput("ssh {} cat {}".format(remotehost, FileName))
if y[0] == 0:
os.system('tput setaf 2')
os.system("ssh {} rm {}".format(remotehost, FileName))
print ("'{}' Deleted Sucessfully".format(FileName))
os.system('tput setaf 7')
else:
os.system('tput setaf 1')
print ("File '{}' Does Not Exists".format(FileName))
os.system('tput setaf 7')