Python socket library can implement TCP and UDP, UNIX sockets in Linux is also possible, some programs in interprocess communication is the use of UNIX sockets, if we want to view its communication information to debug, you can use Python to forge its interface, Get content
Reference: https://docs.python.org/2/library/socket.html
import socketimport os if __name__ == ' _ _main__ ': sock = socket.socket (Socket.AF_UNIX, socket. SOCK_STREAM) if os.path.exists ('/tmp/unix.d '): os.unlink ('/tmp/unix.d ') sock.bind ('/ Var/run/rrdcached.sock ') sock.listen (5) while True: Connection,address = sock.accept () print "data : %s"%connection.recv (1024x768) #connection. Send ("Hello") connection.close ()
Reference: http://www.2cto.com/os/201305/210033.html
Bash under string operations:
Support ${parameter:offset:length},${parameter:offset}
[Email protected] ~/test $ string= ' Hello '
[Email protected] ~/test $ echo ${string:1:3}
Gl.
[Email protected] ~/test $ echo ${string:1}
Ello
[Email protected] ~/test $ echo $
/bin/bash
Dash: Not supported, workaround: Use expr or cut external commands instead
$ String= ' Hello '
$ expr substr "$string" 2 3
Gl.
$ echo "$string" | Cut-c2-4
Gl.
$ expr substr "$string" 2 "${#string}"
Ello
$ echo "$string" | cut-c2-
Ello
$ echo $
Dash
$
This article is from the "Danielqu" blog, make sure to keep this source http://qujunorz.blog.51cto.com/6378776/1942404
Python socket for UNIX socket and dash string operation