Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 8291  / 2 Years ago, mon, july 18, 2022, 3:33:31

I use a Php script which is actually for sending sms from the terminal using an online sms service 160by2



What it does is opens the terminal,asks for the number then the sms and it is sent...



Now i want the text in that sms to be copied to a new file everytime.



for example like text1.txt then text2.txt and it goes on incrementing every time.



If its not possible from php script then may be i can rite a shell script that first executes the php script and then makes the new file with some command and copies the text in the sms into that file.



I want to know that command( i guess pipelining is also used) and also,how to make the file name different everytime?



I don't know shell scripting.



but in a normal programing language,like c/c++/java,the way would be a loop in which a variable is incremented everytime and then passed as a parameter to the name..is anything like this possible in shell scripting?


More From » php

 Answers
3

Your script should be modified to do two additional things:




  1. Generate a unique filename for the text message (based on date, time, etc.)

  2. Write the number $phno and message $msg to this file



We can do the former using the PHP date function, and the latter using the file_put_contents function.



All you need to do is insert these two lines of code after the phone number and message have been entered:




$textfilename="text ".date("Y-m-d His").".txt";
file_put_contents ($textfilename, $phno."
".$msg."
");



  • Sample output, in file text 2012-08-21 195239.txt:



    1800LOLCATS
    ICANHAZCHEEZBURGER?


[#36479] Tuesday, July 19, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ipentainer

Total Points: 112
Total Questions: 113
Total Answers: 113

Location: Guernsey
Member since Tue, Jul 6, 2021
3 Years ago
;