You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by Piviul <pi...@riminilug.it> on 2020/04/01 09:59:41 UTC

Re: guacamole and wake-on-LAN

ivanmarcus ha scritto il 15/03/20 alle 02:57:
> I've already written a Python script that reads the log and sends the 
> magic packet as needed. It's been running for a couple of years now, 
Many thanks Ivan! I would like to use your script but when I run it I 
get the error:
$ ./guac_wol.py
   File "./guac_wol.py", line 64
     logfile =
             ^
SyntaxError: invalid syntax

I don't know python and I can't understand why I get this error in your 
script...

Piviul

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: guacamole and wake-on-LAN

Posted by ivanmarcus <iv...@yahoo.com.INVALID>.
Well that answers something I was curious about...

... the online Nabble instance doesn't display Unicode 6.0 chrs (well, a 
thumbs up U+1F44D at least), but it does pass it on in email.

Anyway I'm pleased the WOL script's working with the right NIC :-)


On 3/04/2020 7:29 p.m., ivanmarcus wrote:
> 👍
>
> On 3/04/2020 7:10 p.m., Piviul wrote:
>


Re: guacamole and wake-on-LAN

Posted by ivanmarcus <iv...@yahoo.com.INVALID>.
👍

On 3/04/2020 7:10 p.m., Piviul wrote:
> ivanmarcus ha scritto il 01/04/20 alle 15:37:
>> First of all you can check if the WOL function is working correcly in 
>> the machine you're trying to wake up by using the 'wakeonlan' command 
>> from your Guacamole machine.
>>
>> eg. wakeonlan 2D:4A:54:58:FB:FA (obviously changing the MAC to the 
>> correct one for your target machine). Etherwake would also do the 
>> same job.
>>
>> If wakeonlan isn't installed just apt-get install wakeonlan (assuming 
>> a debian-based distro).
>>
>> If that doesn't work you'll need to sort out the target machine. 
>> Otherwise if it does work then there could be a problem with the 
>> format of the macs.list file, or the id number/MAC in the macs.list 
>> file isn't correct for that connection.
>>
>> To check this out - tail catalina.out when you attempt a connect to 
>> the machine and ensure the connection number is the same as that in 
>> the macs.list file (with associated MAC for that machine).
>>
>> The WOL part of the code is fairly standard, but if all else fails 
>> you could try something like this (save it into a new file, eg 
>> wol2.py, and run it same as the other - you may need to change the 
>> location of the macs.list file, and catalina.out if you're using a 
>> different version of Tomcat):
> Thank you very much indeed; in effect I was trying to test your script 
> with a notebook that was connected to the lan using the wireless card 
> and the wireless doesn't seems to support WOL... (^_^;)
>
> Any way with network cards WOL capable your script seems to work very 
> well...
>
> Thank you very much!
>
> Piviul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
> For additional commands, e-mail: user-help@guacamole.apache.org
>


Re: guacamole and wake-on-LAN

Posted by Piviul <pi...@riminilug.it>.
ivanmarcus ha scritto il 01/04/20 alle 15:37:
> First of all you can check if the WOL function is working correcly in 
> the machine you're trying to wake up by using the 'wakeonlan' command 
> from your Guacamole machine.
> 
> eg. wakeonlan 2D:4A:54:58:FB:FA (obviously changing the MAC to the 
> correct one for your target machine). Etherwake would also do the same job.
> 
> If wakeonlan isn't installed just apt-get install wakeonlan (assuming a 
> debian-based distro).
> 
> If that doesn't work you'll need to sort out the target machine. 
> Otherwise if it does work then there could be a problem with the format 
> of the macs.list file, or the id number/MAC in the macs.list file isn't 
> correct for that connection.
> 
> To check this out - tail catalina.out when you attempt a connect to the 
> machine and ensure the connection number is the same as that in the 
> macs.list file (with associated MAC for that machine).
> 
> The WOL part of the code is fairly standard, but if all else fails you 
> could try something like this (save it into a new file, eg wol2.py, and 
> run it same as the other - you may need to change the location of the 
> macs.list file, and catalina.out if you're using a different version of 
> Tomcat):
Thank you very much indeed; in effect I was trying to test your script 
with a notebook that was connected to the lan using the wireless card 
and the wireless doesn't seems to support WOL... (^_^;)

Any way with network cards WOL capable your script seems to work very 
well...

Thank you very much!

Piviul

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: guacamole and wake-on-LAN

Posted by ivanmarcus <iv...@yahoo.com.INVALID>.
First of all you can check if the WOL function is working correcly in 
the machine you're trying to wake up by using the 'wakeonlan' command 
from your Guacamole machine.

eg. wakeonlan 2D:4A:54:58:FB:FA (obviously changing the MAC to the 
correct one for your target machine). Etherwake would also do the same job.

If wakeonlan isn't installed just apt-get install wakeonlan (assuming a 
debian-based distro).

If that doesn't work you'll need to sort out the target machine. 
Otherwise if it does work then there could be a problem with the format 
of the macs.list file, or the id number/MAC in the macs.list file isn't 
correct for that connection.

To check this out - tail catalina.out when you attempt a connect to the 
machine and ensure the connection number is the same as that in the 
macs.list file (with associated MAC for that machine).

The WOL part of the code is fairly standard, but if all else fails you 
could try something like this (save it into a new file, eg wol2.py, and 
run it same as the other - you may need to change the location of the 
macs.list file, and catalina.out if you're using a different version of 
Tomcat):


#!/usr/bin/env python2

import subprocess, csv, sys

logfile = 
subprocess.Popen(['tail','-F','/var/log/tomcat8/catalina.out'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)

while True:
     line = logfile.stdout.readline()
     with open('/home/user/macs.list') as inifile:
         reader = csv.DictReader(inifile)
         if 'connected to connection' in line:
             q1 = line.find("\"")
             q2 = line.find("\"",q1+1)
             q3 = line.find("\"",q2+1)
             q4 = line.find("\"",q3+1)
             user = line[q1+1:q2]
             conn_num = line[q3+1:q4]
             for row in reader:
                 if(row['id']) == conn_num:
#                    print (conn_num)
#                    print(row['mac'])
                     m=(row['mac'])
#                    print (m)
                     subprocess.call (["wakeonlan", (m)])


This is largely the same code but it'd call wakeonlan to wake the 
machine up, and pass it the correct MAC. You can remove the comments 
from the print statements to check how the code is performing and if 
it's got the correct detail (the connection number and MAC address 
should appear in your terminal when a connection is attempted).



On 2/04/2020 2:08 a.m., Piviul wrote:
> Piviul ha scritto il 01/04/20 alle 14:33:
>> ivanmarcus ha scritto il 01/04/20 alle 13:01:
>>> [...]
>>> "logfile = 
>>> subprocess.Popen(['tail','-F','/var/log/tomcat7/catalina.out'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)" 
>>> - all on the one line.
>>
>> thank you very much Ivan! ...but I get another error:
>> $ guac_wol.py
>> Traceback (most recent call last):
>>    File "./guac_wol.py", line 88, in <module>
>>      if(row['id']) == conn_num:
>> KeyError: 'id'
> ooops, it's my fault, the macs.list was not configured properly...
>
> Any way doesn't seems to works... in effect it's the WOL function that 
> doesn't wake up the PC...
>
> Piviul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
> For additional commands, e-mail: user-help@guacamole.apache.org
>


Re: guacamole and wake-on-LAN

Posted by Piviul <pi...@riminilug.it>.
Piviul ha scritto il 01/04/20 alle 14:33:
> ivanmarcus ha scritto il 01/04/20 alle 13:01:
>> [...]
>> "logfile = 
>> subprocess.Popen(['tail','-F','/var/log/tomcat7/catalina.out'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)" 
>> - all on the one line.
> 
> thank you very much Ivan! ...but I get another error:
> $ guac_wol.py
> Traceback (most recent call last):
>    File "./guac_wol.py", line 88, in <module>
>      if(row['id']) == conn_num:
> KeyError: 'id'
ooops, it's my fault, the macs.list was not configured properly...

Any way doesn't seems to works... in effect it's the WOL function that 
doesn't wake up the PC...

Piviul

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: guacamole and wake-on-LAN

Posted by Piviul <pi...@riminilug.it>.
ivanmarcus ha scritto il 01/04/20 alle 13:01:
> [...]
> "logfile = 
> subprocess.Popen(['tail','-F','/var/log/tomcat7/catalina.out'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)" 
> - all on the one line.

thank you very much Ivan! ...but I get another error:
$ guac_wol.py
Traceback (most recent call last):
   File "./guac_wol.py", line 88, in <module>
     if(row['id']) == conn_num:
KeyError: 'id'


:(

Piviul

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
For additional commands, e-mail: user-help@guacamole.apache.org


Re: guacamole and wake-on-LAN

Posted by ivanmarcus <iv...@yahoo.com.INVALID>.
Piviul,

It looks as if the mailing list has introduced a new line where there's 
not meant to be one. Apologies for not noticing that earlier.

The line "logfile =" is meant to read:

"logfile = 
subprocess.Popen(['tail','-F','/var/log/tomcat7/catalina.out'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)" 
- all on the one line.

I suspect in your script you'll just need to bring up the text in line 
below "logfile =" and tack it on the end for it to work.


On 1/04/2020 10:59 p.m., Piviul wrote:
> ivanmarcus ha scritto il 15/03/20 alle 02:57:
>> I've already written a Python script that reads the log and sends the 
>> magic packet as needed. It's been running for a couple of years now, 
> Many thanks Ivan! I would like to use your script but when I run it I 
> get the error:
> $ ./guac_wol.py
>   File "./guac_wol.py", line 64
>     logfile =
>             ^
> SyntaxError: invalid syntax
>
> I don't know python and I can't understand why I get this error in 
> your script...
>
> Piviul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@guacamole.apache.org
> For additional commands, e-mail: user-help@guacamole.apache.org
>