Shell simulation in PHP