0

I have a script that send sms for a trigger using a sms gateway. The command to send sms used is curl as below:

curl 'http://www.example.com/push/server.php?user=******&pass=*******&sid=******&sms=Test+SMS+Check&msisdn=xxxxxxxxxxxxx&csmsid=123456789'

It get reply as an xml format as below:

<?xml version='1.0' encoding='ISO-8859-1' ?><REPLY><PARAMETER>OK</PARAMETER><LOGIN>SUCCESSFULL</LOGIN><PUSHAPI>ACTIVE</PUSHAPI><STAKEHOLDERID>OK</STAKEHOLDERID><PERMITTED>OK</PERMITTED><SMSINFO><MSISDN>xxxxxxxxxxxxx</MSISDN><SMSTEXT>Test+SMS+Check</SMSTEXT><CSMSID>123456789</CSMSID><REFERENCEID>2020050321383271896124009</REFERENCEID></SMSINFO></REPLY>

Now I want to track the count and list of sms sent for billing issue. That's why I need to convert the output xml response to either a text file or a csv or a xlx file that will append each response to a line and count total number of sent sms.

  • Just appending that single line of XML to a text file would allow you to count the number of lines in the file with wc -l to get the number of SMS' sent. Let me know if it needs to be more sophisticated than that. – Kusalananda May 3 at 16:54
  • Yes, that will work but if I want to keep record of those responses in a human readable format then I might need a csv type format. – Tasbir May 3 at 18:38
0

Not sure I understand, but try this...

your_command | tee -a logfile

this will run your command and append to a file called "logfile", you can then look in the logfile, do wc -l against it, etc.

| improve this answer | |
  • tnx for your response, Yes, that will work but if I want to keep record of those responses in a human readable format then I might need a csv type format. – Tasbir May 6 at 5:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.