Say my user gives a variable; can I use it in a system call?
I have tried with no love - so basically I take the user input and make a shell
file filled with the variables and then run it - then remove it. I feel it is an atrocious way to do business.
I would like to see the variable declared, assigned, placed in the call, executed.
Using system calls this way really puts your code into danger. With bigger programs, it creates a lot of errors that are really hard to be detected, unless you use one of those programs, such as checkmarx as help. Practicing on doing things without it might help in the future and that's why I recommend it.
depending on what you are actually doing, it may be worthwhile to have the actual shell script file out there with parameters instead of a full on c++ program. It just depends, but I believe everything you did here was doable in the scripting language, with no c++ needed at all. There is a break even point where things doable in scripting become easier in the c++, and then impossible to do in the script language, but this looks to be on the 'easier to do without c++ at all' side of that equation.