File size: 462 Bytes
5b26c0d
 
 
 
 
1b6959a
5b26c0d
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import subprocess

# 定义 shell 脚本的路径
script_path = '/home/user/app/a.sh'

# 使用 subprocess.run 来运行 shell 
result = subprocess.run(['bash', script_path], capture_output=True, text=True)

# 打印输出和错误
print("Output:", result.stdout)
print("Error:", result.stderr)

# 检查返回码
if result.returncode == 0:
    print("Script executed successfully")
else:
    print("Script execution failed with return code:", result.returncode)