running shell functions based on user input.

This is a discussion on running shell functions based on user input. within the Linux Programming forums, part of the Platform Specific Boards category; I want to use the system() function to change directories, and run a few programs based on user input.
Code ...

edit: My question still stands, though, as I now need to do other commands that involve some user input. example: ./sox chimes.wav -r 8000 -c 1 -u -1 cchimes.wav where chimes.wav and cchimes.wav are user defined.

u can also use snprintf() function to accept command/data from the user and place that in the buffer and pass the same to the system()...this will solve the issue...otherwise u can also use exec() functions, eg. execvp() and pass the array of command and their options to get executed

ya thats correct...the child process gets executed and the control never returns to the parent process...so depending on ur requirement u can use execvp()...if u want control back to the parent process, use snprintf() to copy the exact command in the buffer and pass that to the system()

Be careful to sanitize "path" if it comes from user input. As it is, it looks like a good place for command injection. (Of course, that only applies if this is somehow externally reachable. But it is something to keep in mind.)

Be careful to sanitize "path" if it comes from user input. As it is, it looks like a good place for command injection. (Of course, that only applies if this is somehow externally reachable. But it is something to keep in mind.)

I have no idea what that means

My very first experience with terminal was only a couple of weeks ago, and as I've got nobody around to help me out, and I'm to busy during the day to put a huge amount of effort into it I'm moving pretty slowly.