in reply to problems with exec command
Your script is a huge security problem with both exec and system. Somebody passes a "name", and you embed it in a shell command. It may contain a ";" and an arbitrary shell command.
Read the system() documentation about how you can pass the arguments as an array. And also filter the input. Allow only alphabetic characters, or only specific names.