How to send multiline data to curl from a script?
Bo Berglund
bo.berglund at gmail.com
Fri Sep 3 14:42:53 UTC 2021
I have created a script that is used to execute on startup of the Linux machine
to report the external and internal IP addresses as well as the MAC of the
interfaces.
This script extracts the various items from the system, then packages the data
in a call to a php script on my website. This in turn stuffs the data into an
email sent to me.
This works well using the following command (after extracting the needed data
items):
curl --data "addreth=$AddrEth" --data "name=$MyName" --data "addrwifi=$AddrWiFi"
--data "macaddreth=$MacEth" --data "macaddrwifi=$MacWiFi"
http://mydomain.com/php/ipreport.php
The website ipreport.php script reads these single word items as POST data like
so:
$addreth = $_POST['addreth'];
Now I would like to create a new script that works similar to the one above but
with one "body" field that can hold multiple lines of data, which are to be
added to the end of the resulting mail message body....
Question:
---------
How do I handle the line breaks in the curl call to the php script so that the
complete message will be read by the
body = $_POST['body']
php statement?
--
Bo Berglund
Developer in Sweden
More information about the ubuntu-users
mailing list