-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
25 lines (21 loc) · 842 Bytes
/
test.py
File metadata and controls
25 lines (21 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
import subprocess
# Print the current working directory
print("Current Working Directory:", os.getcwd())
script_path = 'vcluster-ssh.sh'
try:
# If the script is not being found, you can explicitly set the path
full_path = os.path.join(os.getcwd(), script_path)
# Check if the script exists at the expected location
if not os.path.exists(full_path):
print(f"Script not found at {full_path}")
else:
# Execute the shell script
result = subprocess.run([full_path], capture_output=True, text=True, check=True)
print("Shell script ran successfully.")
print("Output:", result.stdout)
except subprocess.CalledProcessError as e:
print("Failed to run shell script.")
print("Error:", e.stderr)
except FileNotFoundError:
print(f"Script file {script_path} not found.")