Home > Back-end >  Pass argument in to bash script(curl)
Pass argument in to bash script(curl)

Time:09-26

have script in gitlab,the task is simple, run the script by passing 2 arguments

i use command :

bash <(curl -Ls "https://gitlab.com/sdf/sdf/-/raw/sdf-main-patch-23022/script.sh?inline=false") domain.xyz 8000

in the script, a simple code:

let a=$1
let b=$2

my command work but get error: syntax error: invalid arithmetic operator (error token is ".xyz")

I understand that this is how it is written that arithmetic is being performed .. but you see what I want to do?

Here it is clearly that I am doing something wrong, I do not understand well. in the bash, can someone tell me what is wrong here?

but for example, if you do this, everything works without errors ..

bash <(echo 'echo args: "$1$2"') domain.xyz 8000

help

CodePudding user response:

let command used to evaluate arithmetic expression, so its not able to recognise a dot(.) character as a valid input because dot(.) is not a valid arithmetic operator.

so, if you want to take arguments in a variable, define then without let keyword like given code.

a=$1
b=$2

echo $a
echo $b
  • Related