You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
823 B
25 lines
823 B
#!/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='')
|