Execute plugin not running commands

Suggest, post, or discuss plugins for Deluge
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Execute plugin not running commands

Post by mhertz »

If was me, then would make new script from scratch and only have in it

Code: Select all

#!/bin/bash
echo $(date) > /config/deluge-test.txt
chmod 777 or whatever and +x etc. - Just for testing.

Try run script from 'sudo docker exec -it deluge sh' - and try there 'su nobody -c "/config/scriptname,sh"' etc. And make sure the other torrent you tested was a linux iso, or atleast not something with spaces etc in names - I just test debian and arch iso's, hence for consistency, atleast initially, so on same page. Granted error states not there, but a preceding step in code did find it and was accesable i.e. os.path.isfile() and os.access() or whatever was.

However I also have my deluged in docker running as root - I seem to remember in older times when messing with it alot for troubleshooting something, that it was running as nobody, like you, so not sure why that is. I have in my script to generate docker:

Code: Select all

-e PUID=0 \
-e PGID=0 \
But I always had that i'm pretty sure, and think came from the binhex github docs, have to check though, OK just did and they use that 0 as me in there example - also if exec into the docker and running 'id nobody' to get new number and remake image, then it's 0 both for nobody and root, which I don't understand. Also running in docker 'su nobody -c whoami' states root - I have nobody in my /etc/shadow of docker, but not very good at such user stuff honestly.

I'll have to experiment a little and see if can rebuild my docker to get back to before with nobody - I updated the VM little ago to new ubuntu version and rebuilded docker image as only things changed, so strange.
sage2050
New User
New User
Posts: 2
Joined: Tue Sep 26, 2023 5:31 pm

Re: Execute plugin not running commands

Post by sage2050 »

I got it working but I have no idea how or the implications of why [copyediting my posts from discord]

there was another level of weirdness where #!bin/sh was returning a CRLF error, and i had to edit out the hidden char: https://askubuntu.com/questions/304999/ ... nterpreter
/bin/bash^M: bad interpreter: No such file or directory

The script indicates that it must be executed by a shell located at /bin/bash^M. There is no such file: it's called /bin/bash.

The ^M is a carriage return character. Linux uses the line feed character to mark the end of a line, whereas Windows uses the two-character sequence CR LF. Your file has Windows line endings, which is confusing Linux.

Remove the spurious CR characters. You can do it with the following command:

sed -i -e 's/\r$//' /file/path.sh

it seems like it is very specifically this file that execute is having an issue with

my test script works without issue:
-rwxrwxrwx 1 nobody users 41 Sep 27 14:11 test.sh

my real script returns the file not found error:
-rwxrwxrwx 1 nobody users 354 Sep 27 14:28 deluge-cross-seed.sh

i moved the contents into test.txt and it worked
fucking weird as hell
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Execute plugin not running commands

Post by mhertz »

Cool, as I was just going here to say that I fixed my nobody issue and execute still working fine here, but then see you fixed it, awesome, good job bud, and ambipro, and thanks for reporting the issue. Indeed such hidden control chars and windows/unix diffs can be a pain in a**, and would be nice if that execvpe error where more detailed lol :)

Edit: Sorry reread your post, just run 'dos2unix <file>' on your failing script, or that sed command, or alike(not at my computer now, but think can in vim if using such, run :set ff=unix and ZZ, but from memory, maybe wrong) , Google if in doubt.
User avatar
ambipro
Moderator
Moderator
Posts: 445
Joined: Thu May 19, 2022 3:33 am
Contact:

Re: Execute plugin not running commands

Post by ambipro »

So I assume that whatever you used to create the file was utilizing windows rather than unix formatting and \r\n instead of just \n (CRLF vs LF) - so that \n was the issue I guess?

Weird now that I'm also seeing it in other sections of logs, although I'm not sure its relevant and not just a coincidence now.

Either way, glad you got it working after we spent so much time having you restart and reconfigure :)

For future reference, if you're creating a script - specifically a bash file on windows, using notepad++ you can go to settings and "New Document" and chose whether to use Windows (CRLF) or Unix (LF) for formatting.

Notepad++ ftw.
mhertz
Moderator
Moderator
Posts: 2215
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Execute plugin not running commands

Post by mhertz »

I think you was right in that it wasen't related, as see it in my tests too, e.g. when not having any shebang(and in bunch other errors independant, as you state), and I make my scripts only on linux, and it shows it in the file not bash, and the actual command run hasen't that, better seen in the debug output level output and not just info/warning/error level as default in that docker(though can be seen there too initially, actual command run, not \n I mean). It's just I believe execvpe call of python that is very picky, whereas can run in terminal fine seemingly. As you say, just windows file, or otherwise control chars inserted independently. Also I misread that reply by Cas a little I believe.

Edit: Little confusing my post lol, and just mean you're right in windows control chars being issue(/n etc, don't know if more lol and lazy) inside script, and that your'e too right in that the execute output listing /n was a red herring(unrelated, atleast there(log) but though related in script coincidentally, but error message would have it regardless).
Sonic3R
New User
New User
Posts: 1
Joined: Mon Nov 13, 2023 2:49 pm

Re: Execute plugin not running commands

Post by Sonic3R »

Hi,

I tried to run a sh script in ubuntu and I verified:
* if deluged is running under user as script's user ownership => Yes
* if script is executable => Yes (with chmod u+x test.sh)
* is found on local disk => Yes ( I use realpath to that sh file and I have /home/user/test.sh , that one I paste in command box of Execute plugin )
* delete execute.conf from ~/.config/deluge folder => Yes, it is re-created

the test.sh looks like:

Code: Select all

#!/bin/bash
torrentid=$1
torrentname=$2
torrentpath=$3

echo "${torrentname} ${torrentpath} ${torrentid}" >> /home/user/execute_script.log
The script is not executed in any way (completed, added or removed event)
User avatar
ambipro
Moderator
Moderator
Posts: 445
Joined: Thu May 19, 2022 3:33 am
Contact:

Re: Execute plugin not running commands

Post by ambipro »

After enabling and setting up the execute script, you will need to restart Deluge.

You also didn't include your path in the execute plugin that it would otherwise be running, this may be where the problem lies if you've tried restarting.

If the script is set +x, you can just put it's path....example below

Code: Select all

/home/user/execute.sh
ausrasplex
New User
New User
Posts: 2
Joined: Thu Jan 25, 2024 7:20 am

Re: Execute plugin not running commands

Post by ausrasplex »

I have been reading through the comments and found that none of the above applies to me, yet my bash command still wont run.

I have a log file from Deluge stating that I dont have permission, however the file is set correctly?

Code: Select all

18:16:39 [WARNING ][deluge_execute.core           :1622] Command "/config/plugins/complete.sh" failed with exit code 1
18:16:39 [WARNING ][deluge_execute.core           :1622] stderr: b'/config/plugins/complete.sh: line 3: complete.txt: Permission denied\n/config/plugins/complete.sh: line 7: complete.txt: Permission denied\n'
Any help with what I am doing wrong would be greatly appreciated!
User avatar
ambipro
Moderator
Moderator
Posts: 445
Joined: Thu May 19, 2022 3:33 am
Contact:

Re: Execute plugin not running commands

Post by ambipro »

If you are running it like that, you need to set chmod +x probably
ausrasplex
New User
New User
Posts: 2
Joined: Thu Jan 25, 2024 7:20 am

Re: Execute plugin not running commands

Post by ausrasplex »

It seems like the error is from publishing the log to the file, however even with the right chmod set, it doesn't seem to allow it to write? I did the old chmod -R 777 RunFileBot.log to change the owner and set permissions. Are you saying that I need to add that to the bash script for it to work maybe?

I am looking to run the FileBot docker container I have installed on my Unraid machine to rename and move the files upon completion.

NOTE: Yes, I changed the name of the file to 'RunFileBot.log' to something more legible for me - also to see if changing the name would help!
Last edited by ausrasplex on Thu Jan 25, 2024 10:59 am, edited 5 times in total.
Post Reply