Consolidated all popen calls (and repeated surrounding code) into read_exec