cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
How to get variable to linux command fro
How to get variable to linux command from config file?
Sep 16, 2021 at 12:09pm UTC
suslucoder
(30)
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");
Sep 16, 2021 at 12:18pm UTC
salem c
(3700)
There's no need to spam the forum(s) with the same post.
https://www.cplusplus.com/forum/unices/279962/
Sep 16, 2021 at 12:21pm UTC
suslucoder
(30)
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.
Sep 16, 2021 at 3:20pm UTC
jonnin
(11437)
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
Sep 16, 2021 at 3:24pm UTC
Sep 16, 2021 at 10:16pm UTC
dhayden
(5798)
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.