Menu
Home
Basic information:
Slideshow, watch this first
License
How to compile/install
- Instructions for Windows
How to configure
- Configuring providers
Localizing
How to run/use
SMS file format
- User Data Header
Additional information:
Version history (3.x)
National language shift tables
Hardware compatibility
Status monitor, Statistics file
Event handler, Alarm handler
Blacklist and Whitelist
Support:
Frequently asked questions
SMSTools3 Community
Get SMS Server Tools 3:
Download
Sponsored links
Search
Custom Search
Visitor locations
SMS Server Tools 3 Community
Welcome, Guest. The forum is currently read-only, but will open soon.
Thu Nov 21, 2024 16:26
Login
Register
Search
Active Topics
Terms of Use
Contact Admin
•
SMSTools3 Community
»
Sample scripts / setups
Bottom
C++/Linux Read and Delete Incoming SMS on server (Console)
Login and Post Reply
Page: 1
Author
Post
florit
Bottom
#1
Thu Sep 03, 2015 14:01, 112 months ago.
Member
Registered:
Sep 2015
Posts: 19
Location: Vienna, Austria
here is the Source of getsms:
/* * Description: get and read or delete SMS in Incoming Folder */ #include <dirent.h> #include <cstdlib> #include <iostream> #include <fstream> std::string core1 = "."; std::string core2 = ".."; using namespace std; const char* Version() { #ifdef VERSION return VERSION; #else return ""; #endif } int main () { printf("%s\n",Version()); const char *TROZ = "/var/spool/sms/incoming/";; int len; struct dirent *pDirent; DIR *pDir; pDir = opendir (TROZ); if (pDir == NULL) { printf ("Cannot open directory '%s'\n", TROZ); return 1; } while ((pDirent = readdir(pDir)) != NULL){ if(pDirent->d_name != core1 && pDirent->d_name != core2) { printf ("%s\n", pDirent->d_name); char START[512]; snprintf(START,512,"%s%s",TROZ, pDirent->d_name); std::string STRING; ifstream myfile; myfile.open(START, ios::in); int a=0; string previousLine=""; while(a<1) // To get you all the lines. { for(int i = 0;i < 13;i++){ getline(myfile,STRING); // Saves the line in STRING. if (STRING != previousLine) { previousLine=STRING; cout<<STRING<<endl; // Prints our STRING. } } myfile.close(); string delx = ""; string delc = "y"; printf("\nDelete sms? (y/n): "); getline(cin,delx); if(delx.c_str() == delc){ std::remove(START); //DeleteFile(START); } else { printf("Leave in Inbox ...\n"); } break; } // } else { continue; } // else } closedir(pDir); return 0; }
[ Select ]
[ Expand ]
do not forget make a new group like: smsincoming and set folder /var/spool/sms/incoming to "chmod 777"
compile with this line:
g++ main.cc -o getsms -DVERSION="\"YOUR-Trademark-getsms 0.3 Public Desaster\""
[ Select ]
install like this:
sudo cp getsms /bin/ && sudo chmod +x /bin/getsms
[ Select ]
just run getsms
that makes you happy
Login and Post Reply
Page: 1
•
SMSTools3 Community
»
Sample scripts / setups
Top
Time in this board is UTC.
Privacy Policy
SMS Server Tools 3 Copyright © Keijo Kasvi.