I use Rocket.Chat internally, but I want to be notified of the result of cron processing on the ubuntu server as a chatbot. 
 The curl command is issued from Rocket.Chat by the mechanism of Webhook, but I stumbled upon the method of sending the variable created in the shell executed by cron to the chat with the curl command, so I will leave the solution  p>
 
Receive variables with the curl command so that you can get different results depending on the situation p>
First, check Rocket.Chat for the basic curl command issued by Webhook p>
curl -X POST -H 'Content-Type: application/json' --data '{"text":"Example message","attachments":[{"title":"Rocket.Chat","title_link":"https://rocket.chat","text":"Rocket.Chat, the best open source chat","image_url":"https://rocket.chat/images/mockup.png ","color":"#764FA5"}]}' https://〜〜If you want to skip only plain text, write as follows p>
curl -X POST -H 'Content-Type: application/json' --data '{"text":"hogehoge"}' https://〜〜When using variables, do the following p>
 The conclusion is 
['"+"']
 Surrounded by  p>
curl -X POST -H 'Content-Type: application/json' --data '{"text":"'"$fuga"'"}' https://〜〜If you want to use fixed statements and variables p>
curl -X POST -H 'Content-Type: application/json' --data '{"text":"hogehoge'"$fuga"'"}' https://〜〜Like this p>
 It looks awkward, but now you can use it. 
 Please refer to it if you use it someday.  P>
 
 At first I thought this was only possible when using variables with curl, but 
 Actually, it seems that it was a method used when you want to reuse variables when writing shell scripts etc.  P>
        
Recommended Posts