In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "how to configure the socket ssh environment". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Server side socket,os,time server=socket.socket () server.bind ((, 9999)) server.listen (): conn,addr=server.accept () print (, addr): print () data=conn.recv (1024) data: print () print (, data) cmd_res=os.popen (data.decode ()). Read () print ( Len (cmd_res)) len (cmd_res) = 0: cmd_res=conn.send (str (len (cmd_res.encode () .encode () client_ack=conn.recv (1024) print (, client_ack.decode ()) conn.send (cmd_res.encode ()) print () server.close ()
Client side socket client=socket.socket () client.connect ((, 9999)): cmd=input () .strip () len (cmd) = = 0:client.send (cmd.encode ()) cmd_res_size=client.recv (1024) print (, cmd_res_size) client.send (.encode () received_size=0 received_data=received_size
< int(cmd_res_size.decode()): data=client.recv(1024) received_size +=len(data) received_data +=data : print(,received_size) print(received_data.decode()) client.close()在linux后台运行python脚本 加-u参数才能打印日志 nohup python3 -u sock_ssh_server.py >Py_run.log 2 > 1 & automatically pull up the sh script #! / bin/sh source ~ / .bash_profile ps-ef | grep-v grep | grep'/ usr/local/bin/python3-u / root/sock_ssh_server.py' > / dev/null 2 > & 1 if [$?-eq 0] then echo `date` "- python script is running" > ~ / result.log else nohup / usr/local/bin/python3-u ~ / sock _ ssh_server.py > ~ / py_run.log 2 > 1 & this is the end of fi's "how to configure the socket ssh environment" Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.