Hi, I’m trying to write a script that allows me to move or delete files on a server. I’m running Kodi on an NVIDIA Shield, so Android. My first thought was to do this via SSH and re/move the file directly on the server. This approach basically seems fine but im running into issue which I guess are related to the architecture of android. I cant seem to be able to access SSH from within a Kodi-Script. Has anybody any ideas how to overcome this issue or would you suggest a completely different approach?
Thanks in advance
python:import os, xbmc, xbmcgui, xbmcvfs, time
import subprocess
dialog = xbmcgui.Dialog()
dialog.ok('new Version', 'starting._..')
# Add Termux's bin directory to PATH
termux_path = "/data/data/com.termux/files/usr/bin"
os.environ["PATH"] += os.pathsep + termux_path
# Now try running the SSH command
test_command = "ssh -i /data/data/com.termux/files/home/.ssh/id_rsa -o BatchMode=yes user@Server -p 52 'echo Authentication successful'"
result = subprocess.run(test_command, shell=True, capture_output=True, text=True)
log_file_path = "/sdcard/Android/data/org.xbmc.kodi/files/.kodi/temp/ssh_log.log"
with open(log_file_path, "w") as logfile:
logfile.write("STDOUT:\n")
logfile.write(result.stdout + "\n")
logfile.write("STDERR:\n")
logfile.write(result.stderr + "\n")
logfile.write("Return Code:\n")
logfile.write(str(result.returncode) + "\n")
if result.returncode == 0:
print("SSH command executed successfully.")
dialog.ok('new Version', 'Key-based authentication works')
else:
print("SSH command failed. Check the log for details.")
dialog.ok('new Version', 'SSH command failed. Check the log for details: \n' + result.stderr)