ogclone-engine/admin/Interface/ConsolaRemota.py

29 lines
847 B
Python

import os
import sys
import subprocess
def main(script_path, output_path):
try:
# Make the script executable
os.chmod(script_path, 0o755)
# Execute the script and redirect output
with open(output_path, 'w') as output_file:
result = subprocess.run([script_path], stdout=output_file, stderr=subprocess.PIPE)
# Check if the script execution was successful
if result.returncode != 0:
sys.exit(result.returncode)
except Exception as e:
print(f"An error occurred: {e}")
sys.exit(1)
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python3 ConsolaRemota.py <script_path> <output_path>")
sys.exit(1)
script_path = sys.argv[1]
output_path = sys.argv[2]
main(script_path, output_path)