Help error=13, Permission denied

Continuing the discussion from Disable internet connection of specific echo device on fritz box via script:

Hi,
I tried to change the userprofile with the command which you discribe. But I always get a arrow in the Log file.
Herer are my source code

rule "echoesszimmeranaus"
when
	Item echoanaus changed
then
	createTimer(now) [|
		if (echoanaus.state == OFF) {
			executeCommandLine("/etc/openhab2/scripts/fritzboxprofile.sh 192.168.178.1 password filtprof1071 never", 5000)
		} else {
			executeCommandLine("/etc/openhab2/scripts/fritzboxprofile.sh 192.168.178.1 password filtprof1071 unlimited", 5000)
		}
	]
end
#!/bin/sh

challenge=$(curl -s "http://$1/login_sid.lua?username=admin" | grep -Po '(?<=<Challenge>).*?(?=</Challenge>)')
md5=$(echo -n ${challenge}"-"$2 | iconv -f ISO8859-1 -t UTF-16LE | md5sum -b | awk '{print substr($0,1,32)}') 
response="${challenge}-${md5}"
sid=$(curl -i -s -k -d "response=${response}&username=admin" "http://$1" | grep -Po -m 1 '(?<=sid=)[a-f\d]+' | tail -1)

curl -d "sid=${sid}&edit=$3&time=$4&budget=unlimited&apply=&page=kids_profileedit" "http://$1/data.lua" >/dev/null 2>&1

For the username I tried also a second which has admin rights.

This is the warning message at the log

[WARN ] [lipse.smarthome.io.net.exec.ExecUtil] - Execution failed (Exit value: -559038737. Caused by java.io.IOException: Cannot run program "/etc/openhab2/scripts/fritzboxprofile.sh" (in directory "."): error=13, Permission denied)

Maybe anybody can help me?

Best Regards

ExecuteCommandLine syntax varies by openHAB version, so let’s clear that up first.

Do you get this message in case you add

cd /tmp

between "#/bin/sh and the row that starts with “challenge=” ?

Hi,

did you check the owner and the permission of the file “fritzboxprofile.sh”? You can run “ls -l” in the directory of the file and post the output.

br

I had add sudo in the commando line

executeCommandLine("sudo /etc/openhab2/scripts/fritzboxprofile.sh  password filtprof1071 never", 5000)

So I haven’t an Error on the Log but the userrights aren’t changing in the Fritzbox.
I had made a special user in Fritzbox for chaging the userright. I hope this is correct

Still applies

You can also check for responses

var results = executeCommandLine( ... blah ... )
logInof ("test", "My exec returned " + results)

It looks like that the EXEC Binding isn’t installed.

Off sudo: /etc/openhab2/scripts/fritzboxprofile.sh: command not found
I use openhabe 2.5 and I can't install the EXEC Binding over Paper UI. Is there an additional way to install it

Sorry I thought that the Binding is installed. I Tried it and I didn't receive an error message in Log

Format Error
Herr is the code again, Sorry

Off sudo: /etc/openhab2/scripts/fritzboxprofile.sh: command not found
  • executeCommandLine is an action
  • exec binding is a binding that needs to be installed
  • executeCommandLine is not part of the exec binding
  • according to your code snippets you use executeCommandLine which does not require the exec binding to be installed
  • command not found means that a file / binary or shell script that is to be executed cannot be found
  • as the shell script ( fritzboxprofile.sh ) is before the colon this should mean that your shell script is started to be executed but a command from inside of that shell script is not found
  • you can use a PATH variable inside of the script and add all relevant directories to that environment variable
  • alternatively you may always use full path to any executeable/script/command
  • add debug output to your script that ‘every’ line creates output once the error message appears you should be able to identify which command is the root cause ( because you can see the debug output of the line before )

At first thank you for helping

I found the problem. The userrights are rong. The had only read and writte access.

No I have the next problem. It’s still not changing the user in then fritzbaox. But I no error occur.
How can I debugg the script?

You can add addtional rows to the script like:

echo $challenge > /tmp/debug.txt
echo $md5 >> /tmp/debug.txt
echo $sid >> /tmp/debug.txt

they need to be added after the related variable is set.
Output will be stored in directory /tmp in file debug.txt.

To see result of the last curl command

>/dev/null

can be replaced with

>>/tmp/debug.txt

Pay attention to > versus >>. The first one creates/overwrites a file. The second one appends output to the end of the file.

I found the problem.
A slash was missing in the fritzprofile.sh :wink:
Thank you very much for helping me

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.