If the temperature is available on your switch, can you not enable SNMP on it and read the specific OID to get the info? Far far easier than trying to keep an ssh connection open, I think.
I guess this does depend on the switch type and whether the info is available on the device via SNMP, though. Duncs -----Original Message----- From: lee [mailto:l...@yagibdah.de] Sent: 19 April 2017 02:20 To: beginners@perl.org Subject: how to repeatedly execute a command on a remote machine via a shh login from within a perl program capturing the output? Hi, I'm trying to repeatedly execute a command on a remote machine and to capture the output with a perl program. I have tried Net::OpenSSH and Net::SSH::Perl. Both log in, execute the command, capture the output --- and then log out. According to the log file of the remote machine, Net::OpenSSH logs out by closing the connection after running the command once despite being designed otherwise. Net::OpenSSH is designed to log out after each command. Since I want to execute the command repeatedly (over long periods of time in intervals of maybe 300 seconds), I do not want to close the connection to the remote machine until my perl program is finished. How could this be achieved? The purpose is to get room temperature readings which are stored in a table in a mysql database. I haven't found any device at a reasonable price that would reliably provide such readings. Using lmsensors works, but the readings are too much influenced by the temperature of the server. I have a switch that provides pretty stable temperature readings which I might be able to use instead, and to get those, I have to log in to the switch and issue a command that shows its temperature. Hence I don't want to log in and out all the time just to get a temperature reading. Suggestions for reliably getting a room temperature reading are also welcome. I do not want to use the serial port because I sometimes need it to connect to a console port on a switch or router, and there's only one serial port. I could use the parallel port or usb, though. I'm not really inclined to solder some sort of diy thingy myself as I'd probably overheat the parts and do more damage than anything else; it's just not my thing doing that kind of stuff. If anything fails, I could get away by hooking up a simple thermostat which opens and closes a contact depending on temperature, as long as I can get a reading whether the contact is opened or closed. It won't be a good solution, yet better than nothing. I'm aware that there are USB sticks ("temper") that /might/ work, but from what I've been reading, they seem rather unreliable even if you can get one to work. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/