I have one script that takes the name of argument and its value, like this:
script1.sh --netId netIdValue
However, I'd like to call this command multiple times in another script, for the different values of netId argument. So, in script2.sh I want to read the values of netIdValue from the .txt file and then to call the same command, like this:
while IFS= read -r line; do
netIdValue=$line
./script1.sh --netId $netIdValue
done < netNames.txt
But, this fails, and it seem the problem is that it does not take --netId properly. How can I pass the argument name and its value in script2.sh?
IFS-or is that a typo? You wantIFS=\r\nline endings?bash -x yourscriptand read the trace logs emitted (and edit them into the question). (2) Include the error message in your question; let us evaluate what it "seems". (3) Glenn's comment above is almost certainly your problem.--netId "$netIdValue"is how the above code should be quoted.linevariable instead ofread -r netIdValueto put the value directly into the name you want?)