3 changed files with 44 additions and 4 deletions
			
			
		@ -0,0 +1,25 @@ | 
				
			|||
#!/usr/bin/python3 | 
				
			|||
 | 
				
			|||
# Author: Ali Hatami Tajik (info@alihatamitajik.ir) | 
				
			|||
# Date:   08 May 2023 | 
				
			|||
 | 
				
			|||
import socket | 
				
			|||
import argparse | 
				
			|||
 | 
				
			|||
parser = argparse.ArgumentParser(prog='socknix.py',  | 
				
			|||
                                 description='Sends specified massage to unix socket specified prints out the answer of the server in the stdout.') | 
				
			|||
                                 | 
				
			|||
parser.add_argument('--socket', '-s', required=True,  | 
				
			|||
                    help='address of the UNIX socket in the filesystem') | 
				
			|||
parser.add_argument('--message', '-m') | 
				
			|||
parser.add_argument('--buffer', '-b', type=int, default=1024) | 
				
			|||
 | 
				
			|||
args = parser.parse_args() | 
				
			|||
 | 
				
			|||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) | 
				
			|||
s.connect(args.socket) | 
				
			|||
if args.message: | 
				
			|||
    s.send(args.message.encode()) | 
				
			|||
else: | 
				
			|||
    s.send(input().encode()) | 
				
			|||
print(s.recv(args.buffer).decode(), end='') | 
				
			|||
					Loading…
					
					
				
		Reference in new issue