Linux Newbie: How Do I Use Sudo to run this file?


DZMM

Recommended Posts

I've tried and I've tried to run this file, but I can't get it to work:

 

https://home-assistant.io/docs/ecosystem/hass-configurator/

Quote

 

Copy configurator.py to your Home Assistant configuration directory (e.g /home/homeassistant/.homeassistant)

Make it executable: sudo chmod 755 configurator.py

(Optional) Set the GIT variable in configurator.py to True if GitPython is installed on your system. This is required if you want to make use of the Git integration.

Execute it: sudo ./configurator.py

To terminate the process do the usual CTRL+C, maybe once or twice

 

 

When I try to do this I get:

 

root@Highlander:/mnt/user/appdata/home-assistant# sudo chmod 755 configurator.py                       
root@Highlander:/mnt/user/appdata/home-assistant# sudo ./configurator.py
sudo: unable to execute ./configurator.py: No such file or directory

What am I doing wrong?  Thanks

Link to comment

In your post above you have appdata in the directory path.  Is your HomeAssistant in a docker container?

 

If so you need to be at a bash prompt in the docker container when you type in your commands and the sudo may or may not be needed there.  So enter the following to get to a bash prompt in your container:

"docker exec -it <docker name> /bin/bash"

Edited by BobPhoenix
Link to comment
11 hours ago, BobPhoenix said:

In your post above you have appdata in the directory path.  Is your HomeAssistant in a docker container?

 

If so you need to be at a bash prompt in the docker container when you type in your commands and the sudo may or may not be needed there.  So enter the following to get to a bash prompt in your container:

"docker exec -it <docker name> /bin/bash"

Not sure if I'm doing this right:

 

root@Highlander:~# docker exec -it home-assistant /bin/bash ‘configurator.py’
/bin/bash: ‘configurator.py’: No such file or directory
root@Highlander:~# docker exec -it home-assistant /bin/bash -c 'configurator.py'
/bin/bash: configurator.py: command not found
root@Highlander:~# docker exec -it home-assistant /bin/bash  'configurator.py'
/bin/bash: configurator.py: No such file or directory
root@Highlander:~# docker exec -it home-assistant /bin/bash
root@Highlander:/usr/src/app# sudo configurator.py
bash: sudo: command not found
root@Highlander:/usr/src/app# configurator.py
bash: configurator.py: command not found
root@Highlander:/usr/src/app# ./configurator.py
bash: ./configurator.py: No such file or directory
root@Highlander:/usr/src/app#

 

Link to comment

You first get into the docker with the "docker exec -it home-assistant /bin/bash".  Then go looking with ls command and find your configurator.py command file.  Then copy it to the correct location by looking for the path they want you to put it in.  Then setup permissions correctly.

 

SO:

root@Highlander:~# docker exec -it home-assistant /bin/bash  <-- has colored prompt for me

root@Highlander:~# <find your py file here> <-- has all WHITE prompt if in putty after connecting above (let you know if you connected correctly)

root@Highlander:~# <find your path to copy to here> <-- has all WHITE prompt blah blah blah

root@Highlander:~# cp <your py file> <path>  <-- has all WHITE prompt blah blah blah

root@Highlander:~# <set file permissions here> <-- has all WHITE prompt blah blah blah

root@Highlander:~# exit <-- has all WHITE prompt until you type exit and press enter

root@Highlander:~# <--now back to color prompt

 

If you can't find your py file it means it isn't inside your docker file space you might need to download it inside the docker or use Docker GUI in unraid to map a path to where the file IS.  Then copy it.  To download I believe you can use WGET.

Edited by BobPhoenix
Link to comment

I don't think it's in the docker container - the configurator.py file is in the appdata folder.

 

I've just tried the following and it still doesn't work:

 

root@Highlander:/mnt/user/appdata/home-assistant# python ./configurator.py
  File "./configurator.py", line 1
    !/usr/bin/python
    ^
SyntaxError: invalid syntax

 

Link to comment
18 minutes ago, DZMM said:

I don't think it's in the docker container - the configurator.py file is in the appdata folder.

 

I've just tried the following and it still doesn't work:

 


root@Highlander:/mnt/user/appdata/home-assistant# python ./configurator.py
  File "./configurator.py", line 1
    !/usr/bin/python
    ^
SyntaxError: invalid syntax

 

Are you sure you're not missing the # as the first character in the script?

Link to comment
17 minutes ago, DZMM said:

I don't think it's in the docker container - the configurator.py file is in the appdata folder.

 

I've just tried the following and it still doesn't work:

 


root@Highlander:/mnt/user/appdata/home-assistant# python ./configurator.py
  File "./configurator.py", line 1
    !/usr/bin/python
    ^
SyntaxError: invalid syntax

 

 

Let's rewind this a bit.  Can you explain what you are trying to accomplish?  This script, is it part of a Docker?  If so which one?  Explain what you are trying to accomplish and the forum will be able to better help you.  What I have seen so far is you are trying to run a python script 'in the open' on unRAID.  This is bad.

Link to comment

 

6 minutes ago, unevent said:

 

Let's rewind this a bit.  Can you explain what you are trying to accomplish?  This script, is it part of a Docker?  If so which one?  Explain what you are trying to accomplish and the forum will be able to better help you.  What I have seen so far is you are trying to run a python script 'in the open' on unRAID.  This is bad.

What I'm trying to achieve is in my original post - I've copied a file configurator.py to my appdata folder which is supposed to add new functionality to the home-assistant docker.  If running it is a bad idea, I'll leave it alone. 

 

Using Unraid is my only real experience of running Linux (I've worked in the internet space for nearly 20 years, but I run products & P&Ls and don't code at all for a living)  so this is all new to me.

 

 

configurator.py

Link to comment
32 minutes ago, DZMM said:

 

What I'm trying to achieve is in my original post - I've copied a file configurator.py to my appdata folder which is supposed to add new functionality to the home-assistant docker.  If running it is a bad idea, I'll leave it alone. 

 

Using Unraid is my only real experience of running Linux (I've worked in the internet space for nearly 20 years, but I run products & P&Ls and don't code at all for a living)  so this is all new to me.

 

 

configurator.py

 

Reading up on this script it seems it provides a web-based interface to the configuration.  Will need to know what Docker you are using to determine if you can use this script.

 

 

Link to comment

You will need to be in the Docker container to execute this script.  Copy the 'configurator.py' script to your appdata config directory for the home assistant Docker.  Before moving forward, you need to use a Linux text editor to edit the script and configure for your environment.  Using 'mc' Midnight Commander on unRAID via Telnet/SSH is one way.  Telnet/SSH to unRAID and issue the command below replacing 'container_name' with the name of the container as seen on the Docker tab in unRAID GUI:

docker exec -ti container_name /bin/bash

Assuming your folder map for config is '/config', verify the existence of the configurator.py script in the config folder:

ls /config/conf*.py

After verifying/locating the file, make the script executable:

chmod +x /config/configurator.py

Execute the script:

cd /config
./configurator.py

Follow the instructions from the Hass.io site.

Link to comment
  • 1 year later...

I think you should have been getting the .py file into the docker itself (not the place where configuration.yaml exists in the appdata location) by going into the console relevant to the HA docker image, then pulling the file in there with a wget, but as far as executing it, I'm stuck there.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.