How to get variable to linux command from config file?

Hi everyone. I have a code script that deleting unused logs.
I have this function for it. +5 represents the days. I want to get it from outside, from a config file. How can i do it?

system("find /var/log -name '*.log' -type f -mtime +5 delete");

There's no need to spam the forum(s) with the same post.
https://www.cplusplus.com/forum/unices/279962/
Im sorry. Firsly i will try to post my question that forum. I gave an error. I didnt know i post the same question 2 times.
just do a string..
string blah{"find /var/log -name '*.log' -type f -mtime "}; // +5 delete"};
...
string input;
...
blah += input + " delete";
system(blah.c_str());

you can also use a token for +5 and use string replace on the token.
Last edited on
To avoid security problems, use "/bin/find" instead of just "find".

There are other security problems too, but this is a start.
Topic archived. No new replies allowed.