How to pass a variable in a curl command in shell scripting

前端 未结 3 1383
予麋鹿
予麋鹿 2020-12-13 06:37

I have a curl command:

curl -u ${USER_ID}:${PASSWORD} -X GET \'http://blah.gso.woo.com:8080/rest/job-execution/job-details/${job_id}\'

The

相关标签:
3条回答
  • 2020-12-13 07:28
    userdetails="$username:$apppassword"
    base_url_part='https://api.XXX.org/2.0/repositories'
    path="/$teamName/$repoName/downloads/$filename"
    base_url="$base_url_part$path"**strong text**
    curl  -L -u "$userdetails" "$base_url" -o "$downloadfilename"
    
    0 讨论(0)
  • 2020-12-13 07:31

    I ran into this problem with passing as well, it was solved by using ' " $1 " '

    See connection.uri below

    curl -X POST -H "Content-Type: application/json" --data '
      {"name": "mysql-atlas-sink",
       "config": {
         "connector.class":"com.mongodb.kafka.connect.MongoSinkConnector",
         "tasks.max":"1",
         "topics":"mysqlstock.Stocks.StockData",
         "connection.uri":"'"$1"'",
         "database":"Stocks",
         "collection":"StockData",
         "key.converter":"io.confluent.connect.avro.AvroConverter",
         "key.converter.schema.registry.url":"http://schema-registry:8081",
         "value.converter":"io.confluent.connect.avro.AvroConverter",
         "value.converter.schema.registry.url":"http://schema-registry:8081",
         "transforms": "ExtractField",
         "transforms.ExtractField.type":"org.apache.kafka.connect.transforms.ExtractField$Value",
         "transforms.ExtractField.field":"after"
    }}' http://localhost:8083/connectors -w "\n"
    
    0 讨论(0)
  • 2020-12-13 07:42

    When using variables in shell, you can only use doubles quotes, not single quotes : the variables inside single quotes are not expanded. Learn the difference between ' and " and `. See http://mywiki.wooledge.org/Quotes and http://wiki.bash-hackers.org/syntax/words

    0 讨论(0)
提交回复
热议问题