Telnet/ssh connection to network devices and snmp

Hello folks,…

Prolog I can handle. Networking I struggle with (I have just found)

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 to receive and send data/commands.

Ideally I will create simple output lines and parse with DCG pio to build information structures to parse.

Also I have tried to see if I can get access some data via snmp, but again fighting the lack of knowledge,
so backtracked to the main problem rather then red herrings.

Problem(s)

I could connect to my network device, but found that it was saying (via Putty) ‘Username :’
sadly there was no line feed so struggled to simpy get a line when in prolog.

When connecting successfully? 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 :frowning:

code and output below (just enough to get me to the proplem)

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

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)

I did also spend some time looking at snmp systems and found some usefull data in there, but really want a simple of interrogating devices
parsing looks a doddle.

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 use telnet on my devices
3 - Communicate to devices using snmp protool to get data back for parsing.

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 ?

Gary

This is not the official SWI-Prolog Discourse site. The official site is at https://swi-prolog.discourse.group/

You will need to sign-up there and then post your question.

Out of curiosity how did you find this site? While we don’t hide this site, we also don’t go around adding official links to this site.

Also this entire topic will lost when we do future work on this site.