[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Simple write to files-request for help
- From: Francesco Abbate <francesco.bbt@...>
- Date: Thu, 29 Dec 2011 17:05:08 +0100
2011/12/29 email@example.com <firstname.lastname@example.org>:
> Anyone know how to write to 3 output files - see below.
> This writes to console window ok for the entire file, but
> I would like to write to three separate files.
> My Progress,
> here is my program - how do I open and print to 3 files, this does not work.
> io.open ("MAC.dat" , w)
> io.open ("IP1.dat" , w)
> io.open ("IP2.dat" , w)
> for s in io.lines("2011_12_02_sfccnetword20.txt") do
> for a in s:gmatch("DHCP.-to MAC address (.-),") do print("MAC",a) end
> for a in s:gmatch("DoS.-from ip.%[(.-)%]") do print("IP1",a) end
> for a in s:gmatch("LAN.-%] from (.-):.- to") do print("IP2",a) end
I guess you should use io.write instead of print so that you can write
in the appropriate file. print always write into the stdout.
I recommend to study the Lua documentation about input/output.