簡體   English   中英

我的shell腳本中的shell腳本沒有獲取int變量

[英]my shell script inside shell script not getting int variable

我使用scrip1.sh獲取int值a和b,然后嘗試將這些值傳遞到另一個腳本(例如script2.sh),該腳本位於script1.sh內,其中script2.sh具有URL,並且期望該變量ab例如。 http:// download- $ a- $ b /。 在我的腳本中,URL沒有獲取我的輸入變量。

        read  "Enter Build date: " a
        read  "Enter build No: " b
        bash /root/script2.sh $a $b

不要添加任何其他帶有read的語句。

這樣嘗試

在script1.sh中

#!/bin/bash
echo "Enter Build date: "
read a
echo "Enter build no: "
read b
bash /root/script2.sh $a $b

在script2.sh中

#!/bin/bash
a=$1
b=$2
echo "http://download-$a-$b/."

注意:回顯“ http:// download- $ a- $ b /”。 僅供參考以顯示值。 獲得價值后即可進行所需的操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM