Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
Added support for arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
highghlow committed Jun 2, 2023
1 parent 82c49a8 commit a2517e7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/runremote/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import os as oslib

def run(host, user, password, cmd, get_result=False):
command = ["sshpass", "-p", password, "ssh", "-t", "-q", "-o", "StrictHostKeyChecking=no", f"{user}@{host}"] + cmd.split()
if isinstance(cmd, str):
cmd = cmd.split()
command = ["sshpass", "-p", password, "ssh", "-t", "-q", "-o", "StrictHostKeyChecking=no", f"{user}@{host}"] + cmd
if get_result:
p = subprocess.Popen(command, stdout=PIPE, stderr=PIPE, stdin=PIPE)
p.wait()
Expand All @@ -21,11 +23,13 @@ def main():
parser.add_argument("--user", required=True, type=str, help="Remote user")
parser.add_argument("--pass", required=False, type=str, help="Remote password")
parser.add_argument("file", type=str, help="Executable to launch")
parser.add_argument("args", nargs="*", help="Executable arguments")
args = parser.parse_args()
host : str = args.host
user : str = args.user
password : str | None = getattr(args, "pass")
file : str = args.file
arguments = args.args

if password is None:
password = getpass.getpass()
Expand All @@ -44,8 +48,8 @@ def main():
print("Copying failed")
exit(1)
if os == "windows":
exit(run(host, user, password, "_a.exe"))
exit(run(host, user, password, ["_a.exe"] + arguments))
elif os == "linux":
exit(run(host, user, password, "./_a.exe"))
exit(run(host, user, password, ["./_a.exe"] + arguments))

if __name__ == "__main__": main()

0 comments on commit a2517e7

Please sign in to comment.