[英]How to transfer variable value from Python script to a Bash script
我想為 LFS(Linux From Scratch)創建一個包管理器我的想法是使用 Python 腳本來請求文件並將值傳輸到 Bash 腳本,但到目前為止我無法傳輸值,這是我的代碼
import os
import subprocess
path="/sources/"
inputfile=input("please enter input file:")
inputfile1=inputfile
subprocess.call(['bash', 'run.sh', 'inputfile1'])
這是 Bash 腳本(它很短,因為它只是一個測試)
path="hello world"
echo $path
echo $inputfile1
請嘗試以下操作:
inputfile=input("please enter input file:")
subprocess.call(['bash', 'run.sh', inputfile])
如果要獲取輸出,請運行: subprocess.check_output(['bash', 'run.sh', inputfile])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.