FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
learn-python/checkfile.py at master · HelloHuDi/learn-python · GitHub
HelloHuDi
/
learn-python
Public
forked from
tanteng/learn-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
learn-python
/
checkfile.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (25 loc) · 1004 Bytes
Breadcrumbs
learn-python
/
checkfile.py
Copy path
File metadata and controls
30 lines (25 loc) · 1004 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
sys
# Import the Modules
import
os
# Import the Modules
# Readfile Functions which open the file that is passed to the script
def
readfile
(
filename
):
print
(
filename
)
f
=
open
(
filename
,
'r'
)
line
=
f
.
read
()
print
(
line
)
def
main
():
filename
=
''
if
len
(
sys
.
argv
)
==
2
:
# Check the arguments passed to the script
filename
=
sys
.
argv
[
1
]
# The filename is the first argument
if
not
os
.
path
.
isfile
(
filename
):
# Check the File exists
print
(
'[-] '
+
filename
+
' does not exist.'
)
exit
(
0
)
if
not
os
.
access
(
filename
,
os
.
R_OK
):
# Check you can read the file
print
(
'[-] '
+
filename
+
' access denied'
)
exit
(
0
)
else
:
print
(
'[-] Usage: '
+
str
(
sys
.
argv
[
0
])
+
' <filename>'
)
# Print usage if not all parameters passed/Checked
exit
(
0
)
print
(
'[+] Reading from : '
+
filename
)
# Display Message and read the file contents
readfile
(
filename
)
if
__name__
==
'__main__'
:
main
()
Back
|
FazBrowse Home
|
New Git URL