You can use the system
function. However I must warn you to be very careful with it. Firstly why this command will send the argument directly to the terminal, which will run according to the user environment. So maybe the command does not do what you expect it to do. If an alias has been defined for mkdir
, or if the executable itself has changed.
Another problem is that with the argument given by the user. If it says that the folder name is documentos && rm -rf /
, you will cause damage to the computer if you run the command like that. It is something very similar to SQL Injection (search).
The solution is to do what you want to do with the command, without using the command. For example, if you want to create a directory, how about using the function mkdir
that is perfectly secure and does exactly what the documentation says it does? In short: look for alternatives.