def dealarm_shell(tube):
 tube.clean()
 tube.sendline('which python || echo')
 if tube.recvline().startswith('/'):
  tube.sendline('exec python -c "import signal, os; signal.alarm(0); os.execl(\'$SHELL\',\'\')"')
  return tube
 tube.sendline('which perl || echo')
 if tube.recvline().startswith('/'):
  tube.sendline('exec perl -e "alarm 0; exec \'${SHELL:-/bin/sh}\'"')
  return tube
 return None

def dealarm_shell ( tube ) : tube . clean ( ) tube . sendline ( 'which python || echo' ) if tube . recvline ( ) . startswith ( '/' ) : tube . sendline ( 'exec python -c "import signal, os; signal.alarm(0); os.execl(\'$SHELL\',\'\')"' ) return tube tube . sendline ( 'which perl || echo' ) if tube . recvline ( ) . startswith ( '/' ) : tube . sendline ( 'exec perl -e "alarm 0; exec \'${SHELL:-/bin/sh}\'"' ) return tube return None
given a tube which is a shell .