Use the backtick notation if you want to get the output directly (but thread blocking). PHP: $username = `whoami`;