Use proc_open instead echo redirects.