-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsend.py
27 lines (27 loc) · 886 Bytes
/
psend.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python
import pika
import sys
import os
def sndmsg(id):
#message = id + ":" + pip
message = id
credentials = pika.PlainCredentials(username= 'test', password='test')
parameters = pika.ConnectionParameters(host='145.100.130.148',
port=5672,
virtual_host= '/',
credentials=credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='',
routing_key='hello',
body= message)
print(" [x] Sent 'Hello World!'")
connection.close()
if __name__ == '__main__':
if len(sys.argv) < 1:
print("Usage: python3 <id> <public ip>")
else:
id = sys.argv[1]
#pip = sys.argv[2]
sndmsg(id)