Using cURL to send JSON within a BASH script

前端 未结 1 1904
梦如初夏
梦如初夏 2021-02-08 04:07

Alright, here\'s what I\'m trying to do. I\'m attempting to write a quick build script in bash that will check out a private repository from GitHub on a remote server. To do thi

相关标签:
1条回答
  • 2021-02-08 05:07

    It's not certain, but it may help to quote where you use public_key, i.e.

    curl -u 'username:password' \
       -d '{"title":"Test Deploy Key", "key":"'"$public_key"'"}' \
       -i https://api.github.com/repos/username/repository/keys
    

    Otherwise it will be much easier to debug if you use the shell's debugging options set -vx near the top of your bash script.

    You'll see each line of code (or block (for, while, etc) as it is in your file. Then you see each line of code with the variables expanded to their values.

    If you're still stuck, edit your post to show the expanded values of variables for the problem line in your script. What you have looks reasonable at first glance.

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