I am attempting to start mplayer. My filename contains spaces and these should be escaped. This is the code I am using:
@player_pid = fork do
exec \"/usr
Please never use the "single command line" form of exec
, that leaves you open to all the usual quoting and injection issues and pointlessly launches a shell. From the fine manual:
exec(cmdname, arg1, ...)
command name and one or more arguments (no shell)
So instead of mucking around with quoting and escaping and what not, just use the shell-less version:
exec '/usr/bin/mplayer', song.file
and bypass the shell completely. Similarly for system.