From a5cabf657dc5ef00d9604497754719d3eb7ec612 Mon Sep 17 00:00:00 2001 From: Flo de QTG <flo@qtg.fr> Date: Sun, 31 May 2020 10:10:49 +0200 Subject: [PATCH] Create a suicid script to remove the current path and kill connection --- suicide.src | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 suicide.src diff --git a/suicide.src b/suicide.src new file mode 100644 index 0000000..f11bc20 --- /dev/null +++ b/suicide.src @@ -0,0 +1,36 @@ +// @author: Flo de Qu'est-ce que tu GEEKes ? +// This suicid script removes scripts folder +// and kills connection + +program_name = program_path.split("/")[-1] + +if params.len < 1 or params[0] == "-h" or params[0] == "--help" then exit("<b>Usage: "+program_name+" [do|dry-run]</b>") + +this_shell=get_shell +this_computer=this_shell.host_computer + +script_folder = this_computer.File(this_computer.current_path) +if script_folder.has_permission("w") then + if "do" == params[0] then + script_folder.delete + else + print("Dry-Run mode!\n") + print("Delete folder: " + this_computer.current_path) + end if +else + print("permission denied") +end if + +procs = this_computer.show_procs +procs_lines = procs.split(char(10)) +for proc_line in procs_lines + proc_details = proc_line.split(" ") + if null != proc_details.indexOf("Terminal") and active_user == proc_details[proc_details.indexOf("Terminal") - 4] then + terminal_pid=proc_details[proc_details.indexOf("Terminal") - 3] + if "do" == params[0] then + print(this_computer.close_program(terminal_pid.to_int)) + else + print("Kill " + terminal_pid) + end if + end if +end for -- GitLab