Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import subprocess
|
| 2 |
+
|
| 3 |
+
# 定义 shell 脚本的路径
|
| 4 |
+
script_path = '/home/user/app/a.sh'
|
| 5 |
+
|
| 6 |
+
# 使用 subprocess.run 来运行 shell 脚本
|
| 7 |
+
result = subprocess.run(['bash', script_path], capture_output=True, text=True)
|
| 8 |
+
|
| 9 |
+
# 打印输出和错误
|
| 10 |
+
print("Output:", result.stdout)
|
| 11 |
+
print("Error:", result.stderr)
|
| 12 |
+
|
| 13 |
+
# 检查返回码
|
| 14 |
+
if result.returncode == 0:
|
| 15 |
+
print("Script executed successfully")
|
| 16 |
+
else:
|
| 17 |
+
print("Script execution failed with return code:", result.returncode)
|