How do \r in lua ? This my code :
for port = 1, 65535 do
local sock = socket.tcp()
local scan = sock:connect("192.168.88.1", port)
sock:close()
if scan then
print("[\27[1m\27[91m+\27[0m] " .. port .. "")
print("Scanning...\r")
end
end
and the result:
[+] 21
Scanning...
[+] 22
Scanning...
[+] 23
Scanning...
[+] 53
Scanning...
[+] 80
Scanning...
[+] 2000
Scanning...
[+] 8291
Scanning...
[+] 8728
Scanning...
[+] 8729
Scanning...
and I want that as soon as a port is displayed the scanning... is erased and reappears at the end so just after the port.
I can't find much documentation on lua, sorry
i try all the print(en="\r") but it's not fine.
print automatically appends a newline character (\n), which you don't want. Instead, you should use io.write. This will however not flush, so you'll have to also use io.flush. Here's a simple example using the Unix sleep command to wait 1s between messages:
for i = 1, 10 do
io.write(("test %02d\r"):format(i))
io.flush()
os.execute("sleep 1")
end
This will continously overwrite test XX with the new value of i until i=10 is reached.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With