Ejemplo n.º 1
0
    print o,v
    parms[o] = v
host = parms['-h']
port = int(parms['-p'])
try:
    file = open(sys.argv[1])
except:
    print "Cannot open query file: "
    sys.exit()
    
print "Host:", host, "port:", port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
while 1:
    line = file.readline()
    if not line:
        netstring.writens(s, 'BYE')
        break
    if line[-1]=='\n':
        line=line[:-1]
    print "retrieving query ",line
    
    netstring.writens(s, 'retrieve_query '+line)
    ret = netstring.readns(s)
    if ret[0] == '0':
        print ret
    else:
        f = open(encode_query(line),'w')
        f.write(ret)
s.close()
Ejemplo n.º 2
0
    parms[o] = v
host = parms['-h']
port = int(parms['-p'])
try:
    file = open(sys.argv[1])
except:
    print "cannot open query file: "
    sys.exit()
    
print "Host:", host, "port:", port
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
while 1:
    line = file.readline()
    if not line:
        netstring.writens(s, 'BYE')
        break
    if line[-1]=='\n':
        line=line[:-1]
    print "adding query ",line
    
    netstring.writens(s, 'add_query '+line)
    ret = netstring.readns(s)
    print "Server returned: ", ret
s.close()





Ejemplo n.º 3
0
except getopt.GetoptError, msg:
    sys.exit(msg)

for o, v in opts:
    print o,v
    parms[o] = v
host = parms['-h']
port = int(parms['-p'])

print "Host:", host, "port:", port
print "Type help for help"
try:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((host, port))
except:
    print "cant connect to host ",host," on port ",port
    sys.exit()
while 1:
    try:
        arg = raw_input("Send: ")
    except KeyboardInterrupt:
        netstring.writens(s, 'BYE')
        break
    if not arg:
        continue
    netstring.writens(s, arg)
    ret = netstring.readns(s)
    print "Returned:", ret
s.close()