add shell init function. read cmd from socket refactor to function.