Logic Machine Forum
Remote shutdown a PC from visualization - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Remote shutdown a PC from visualization (/showthread.php?tid=881)



Remote shutdown a PC from visualization - jetsetter - 03.07.2017

Hi,

Searching to find a way to remotely shut down some PCs from the Visualization, I cam across to this:

Shut Down From Linux
Once you’ve set up the computer, you can also shut it down from a Linux system. This requires the samba-common package installed – you can install it on Ubuntu with the following command:
Quote:
sudo apt-get install samba-common
Once you have, use the following command from a terminal:
Quote:
net rpc shutdown -I ip.address -U user%password


Is there an way to issue a net rpc shutdown command from an LM script?
Thanks in advance


RE: Remote shutdown a PC from visualization - admin - 04.07.2017

You can install Lua + Luasocket on Linux and create a simple script which receives UDP messages on a certain port. Then just do os.execute('poweroff') (or 'sudo poweroff' if not running a root) when a certain message is received.
Code:
sock = require('socket').udp()
sock:setsockname('*', 12345)
sock:settimeout(1)

while true do
  msg = sock:receive()
  if msg and msg == 'shutdown' then
    os.execute('poweroff')
  end
end

Then you can shutdown from LM like this:
Code:
sock = require('socket').udp()
sock:sendto('shutdown', '192.168.1.11', 12345)



RE: Remote shutdown a PC from visualization - jetsetter - 04.07.2017

(04.07.2017, 06:05)admin Wrote: You can install Lua + Luasocket on Linux and create a simple script which receives UDP messages on a certain port. Then just do os.execute('poweroff') (or 'sudo poweroff' if not running a root) when a certain message is received.
Code:
sock = require('socket').udp()
sock:setsockname('*', 12345)
sock:settimeout(1)

while true do
 msg = sock:receive()
 if msg and msg == 'shutdown' then
   os.execute('poweroff')
 end
end

Then you can shutdown from LM like this:
Code:
sock = require('socket').udp()
sock:sendto('shutdown', '192.168.1.11', 12345)

Thank you for the reply but I was asking how to poweroff some windows machines from LM which is linux based...


RE: Remote shutdown a PC from visualization - Jayce - 06.09.2018

Hello, was this topic discussed beyond the last post? I'd also want to shut off Windows desktop PC though LM. Is there a way?


RE: Remote shutdown a PC from visualization - Erwin van der Zwart - 06.09.2018

Hi,

That would be a huge security gap (:

BR,

Erwin


RE: Remote shutdown a PC from visualization - admin - 06.09.2018

You can install a telnet server and then issue shutdown from LM via LuaSocket.