Compare commits
No commits in common. "3957b7a2dd814b9deefe39773a565b29a554120c" and "2580c3e87490db069386fdd745ab74b015ea5cea" have entirely different histories.
3957b7a2dd
...
2580c3e874
40
netrun.py
40
netrun.py
|
@ -2,39 +2,17 @@ import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def launch(command, data):
|
|
||||||
if isinstance(command, str):
|
|
||||||
command = [command]
|
|
||||||
elif isinstance(command, tuple):
|
|
||||||
command = list(command)
|
|
||||||
elif not isinstance(command, list):
|
|
||||||
raise ValueError("`command` must be `list`, `tuple`, or `str`")
|
|
||||||
|
|
||||||
return subprocess.run(command, input=data)
|
|
||||||
|
|
||||||
|
|
||||||
def yn(question, options="yn"):
|
|
||||||
options = options.lower()
|
|
||||||
|
|
||||||
options_display = f"[{'/'.join(options)}]"
|
|
||||||
full_question = f"{question} {options_display} "
|
|
||||||
|
|
||||||
response = "WILL NEVER OCCUR IN OPTIONS"
|
|
||||||
while not response in options:
|
|
||||||
response = input(full_question).lower().strip()[0]
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
url = sys.argv[1]
|
url = sys.argv[1]
|
||||||
|
|
||||||
content = requests.get(url).content
|
content = requests.get(url).content
|
||||||
|
|
||||||
launch("less", content)
|
subprocess.run(['less'], input=content)
|
||||||
|
|
||||||
response = yn("Do you want to run this script?")
|
while True:
|
||||||
if response == "y":
|
response = input('Do you want to run this script? [y/n] ').lower().strip()[0]
|
||||||
launch("bash", content)
|
if response == 'y':
|
||||||
else:
|
subprocess.run(['bash'], input=content)
|
||||||
print("Script not run.")
|
break
|
||||||
|
elif response == 'n':
|
||||||
|
print('Script not run.')
|
||||||
|
break
|
||||||
|
|
Loading…
Reference in New Issue
Block a user