#!/bin/9lua --[=[ usage: wrrd server data wrrd /net/cs tcp!maia!8007 wrrd /net/cs tcp!maia.local!8007 wrrd /net/dns www.amazon.com ip --]=] gen=require("gen") function usage() print("usage: wrrd file data") os.exit() end function join(t,pos,sep) -- t: string table sep = sep or " " pos = pos or 1 return table.concat(t,sep,pos) end argopt = gen.argopt arg,opt,r = argopt(arg,":") if arg[1] == nil then usage() end fd = p9.open(arg[1],"rw") if fd == nil then print(arg[1].." not open") os.exit() end data = join(arg,2) p9.seek(fd,0,"end") p9.write(fd,data) p9.seek(fd) ans = p9.read(fd,256) while ans do print(ans) -- /net/tcp/clone 192.168.0.3!8007 ans = p9.read(fd,256) end