0

I have a shell script that only does a curl command to notify my Discord server about an issue. I pass two arguments which I want to add into the data body of the curl command but their values are not interpreted.

My script call:

./notifier.sh usernameArg contentArg

My script:

#!/bin/bash

curl -X POST -H "Content-Type: application/json" -d '{"username": "$1", "content": "$2"}' "https://<discord webhook url>"

But all it sends is {"username": "$1", "content": "$2"}. I also tried to use ${1} and ${2} with same result.

Thanks for your help in advance!

nullpointr
  • 524
  • 4
  • 18

1 Answers1

1

Try this instead.

#!/bin/bash

curl -X POST -H "Content-Type: application/json" -d '{"username": "'$1'", "content": "'$2'"}' "https://<discord webhook url>"
redInk
  • 699
  • 5
  • 11