executing os command
Moderator: leecollings
-
- Posts: 4
- Joined: Monday 18 January 2016 23:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.3530
- Location: Warsaw / Poland
- Contact:
executing os command
question is probalby easy but i cannot overcome problem
here is the script i want to be run
commandArray = {}
if (devicechanged['SWRGB'] == 'On') then
-- for i, v in pairs(otherdevices) do print(i, v) end
os.execute('echo -ne "$(echo fbebfff9950000b959d6 | sed -e 's/../\\x&/g')" | nc -u -w1 192.168.12.24 30977')
end
return commandArray
as You see there are " ' " single quotes in expression so whole line cannot be processed - is there any chance someone tell me how to run it ?
side question:
is there any way to get inside LUA device descryption field ?
Best regards
MR
here is the script i want to be run
commandArray = {}
if (devicechanged['SWRGB'] == 'On') then
-- for i, v in pairs(otherdevices) do print(i, v) end
os.execute('echo -ne "$(echo fbebfff9950000b959d6 | sed -e 's/../\\x&/g')" | nc -u -w1 192.168.12.24 30977')
end
return commandArray
as You see there are " ' " single quotes in expression so whole line cannot be processed - is there any chance someone tell me how to run it ?
side question:
is there any way to get inside LUA device descryption field ?
Best regards
MR
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: executing os command
Puth your code in a shell script and execute that from lua.
Could also be that your quotes need to be escaped \'
Could also be that your quotes need to be escaped \'
-
- Posts: 4
- Joined: Monday 18 January 2016 23:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.3530
- Location: Warsaw / Poland
- Contact:
Re: executing os command
i did try escape - its not working - script runs but nothing happens so i have no idea what went wrong
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: executing os command
Then put the code in a bash script
and call it by
os.execute('path/script.sh')
make sure script.sh is executable, sudo chmod +x script.sh
Code: Select all
#!/bin/bash
echo -ne "$(echo fbebfff9950000b959d6 | sed -e 's/../\\x&/g')" | nc -u -w1 192.168.12.24 30977
os.execute('path/script.sh')
make sure script.sh is executable, sudo chmod +x script.sh
-
- Posts: 110
- Joined: Friday 20 September 2013 18:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.3530
- Location: Finland
- Contact:
Re: RE: executing os command
No. I give up. 

-
- Posts: 4
- Joined: Monday 18 January 2016 23:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.3530
- Location: Warsaw / Poland
- Contact:
Re: executing os command
Thing is that next step i want is to get rgb from colour picker (or at least try it) so calling external script is not really i seek since its a. slower b. u cant push parameters that easy. Was thinking about lua script that is able to do it.
- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: executing os command
This doesn't work either?
And why would that be slower? Quite sure you can't measure the milliseconds difference.
and call it by
os.execute('path/script.sh fbebfff9950000b959d6')
And why would that be slower? Quite sure you can't measure the milliseconds difference.
Code: Select all
#!/bin/bash
RGB="$1"
echo -ne "$(echo $RGB | sed -e 's/../\\x&/g')" | nc -u -w1 192.168.12.24 30977
os.execute('path/script.sh fbebfff9950000b959d6')
-
- Posts: 4
- Joined: Monday 18 January 2016 23:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2.3530
- Location: Warsaw / Poland
- Contact:
Re: executing os command
Ye last night i did that, and works quite nice. Thing is its not only a colour - the whole string is hex and contains few other parameters like MAC address, ip etc. (viewtopic.php?f=51&t=7957#p57175)
I was thinking that those could be put in description of device (switch or rgb switch) so u could have 1 script that works with all of them.
That's why i put "side question"
Anyway method You gave here works so thank You for Your effort
I was thinking that those could be put in description of device (switch or rgb switch) so u could have 1 script that works with all of them.
That's why i put "side question"

Anyway method You gave here works so thank You for Your effort

- Egregius
- Posts: 2592
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: executing os command
You can sent multiple arguments to the script:
and call it by
os.execute('path/script.sh fbebfff9950000b959d6 192.168.12.24 30977')[/quote]
Code: Select all
#!/bin/bash
RGB="$1"
IP="$2"
PORT="$3"
echo -ne "$(echo $RGB | sed -e 's/../\\x&/g')" | nc -u -w1 $IP $PORT
os.execute('path/script.sh fbebfff9950000b959d6 192.168.12.24 30977')[/quote]
Who is online
Users browsing this forum: No registered users and 1 guest