Hello folks,…
Prolog I can handle. Prolog networking I struggle with, (I have just found)
have looked at many examples and I did try and find solutions and could see a number of client/server{mainly} examples, but after 2 days, im pushing the help button
Objective:
I would like to login to a number of my network devices (switch/routers) to receive and send data/commands.
Ideally I would login and capture output to parse with DCG pio to build information structures to then work with.
(I am also looking at access data via snmp, but again fighting the lack of knowledge of networking, so perhaps another topic. *red herrings.)
Problem(s)
I could connect to my network device, but found that it was saying (via Putty) ‘Account :’ sadly there was no line feed so struggled to simpy get a line when in prolog.
When connecting successfully (char by char) ? and getting characters I found the values were not what I was expecting, having spent ages looking at utf8, text modes etc, I struggle to get anywhere
code and output below (just enough to get me to the problem)
go :-create_client(‘10.12.13.14’, 23).
create_client(Host, Port) :-
tcp_socket(Socket),
tcp_connect(Socket, Host:Port),
tcp_open_socket(Socket, In, _Out),
repeat,
get_byte(In, CODE),
write(CODE),nl,
fail.
results…
?- go.
255
253
24
255
253
32
255
253
35
255
253
39
I investicated Bom’s and FF,FE’s but got nowhere (im ff,fd)
However when using ssh connectivity to the same device, could see a header but then nothing as it most likley went off to the sshland.
So another red herring came (ssh connectivity)
Ideal World
1 - to connect to Telenet and have a simple chat (read_line(s) and respond )
2 - as (1) but ssh, as i dont really want to use telnet on my devices
3 - generate and read an snmp output
Conclusion
I have learnt lots about prolog networking tcp/udp, snmp and ssh
but sadly the number of permuations for a beginner in that field has outwhitted me
Anyone out there that can help or has done this so i can reuse?