Skip to content

Commit

Permalink
added functionality to save output to the RPi
Browse files Browse the repository at this point in the history
  • Loading branch information
bourbonbourbon committed Sep 25, 2023
1 parent 2e9c30f commit df4cd31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
from dotenv import load_dotenv
import re
from datetime import datetime

def establishConnection(ssh_server, ssh_port, user, pasd):
ssh_client = paramiko.client.SSHClient()
Expand All @@ -28,7 +29,9 @@ def isCommandInstalled(base_cmd, ssh_client):

def runCommand(base_cmd, arguments):
try:
full_command = f"{base_cmd} {arguments}"
makedir = f"mkdir -p $HOME/offloaded_scans/ && "
out_redirect = f"| tee $HOME/offloaded_scans/{datetime.now().strftime(f'%d-%m-%Y_%H-%M-%S_{base_cmd}')}.txt"
full_command = f"{makedir} {base_cmd} {arguments} {out_redirect}"
stdin, stdout, stderr = ssh_client.exec_command(full_command)
output = stdout.read().decode('utf-8')
print(output)
Expand All @@ -44,7 +47,7 @@ def runCommand(base_cmd, arguments):
if len(sys.argv) != 3 or sys.argv[1] == '-h':
print("Usage: python3 script.py <base command> <arguments>")
sys.exit(1)

base_cmd = sys.argv[1]
arguments = sys.argv[2]

Expand Down
1 change: 1 addition & 0 deletions todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
- [x] create venv
- [x] installation instructions
- [x] update readme
- [x] save output to file (as datetime-base_cmd.txt)

0 comments on commit df4cd31

Please sign in to comment.