I'm trying to launch a script bash from another one using sudo.
Here is my first script test.sh
#!/bin/bash
echo "test.sh" $1 $2 $3 >>/home/pi/test.log
sudo ./temp.sh "$1" "$2" "$3" >>/home/pi/test.log &
echo "test.sh done!" >>/home/pi/test.log
When I run
./test.sh a b c
in my console, it works. The second script is launched with args! But when the first script is launched from an other tools (Deluge Execute plugin), the second script is never launched. It looks like a problem with permissions.
Update : I rename the second script to temp.sh and its make an echo in a second file
#!/bin/bash
torrentid=$1
torrentname=$2
torrentpath=$3
echo " Details: " $torrentid $torrentpath $torrentname >> /home/pi/temp.log
It works when launched by command line, but not by Deluge.
Update 2 : The second script is voluntary launch in a second shell/env with & because it will make a long action. I do this because when a script is launched & executed by deluge plugin, deluge is freezed during the execution. So I need a script that launches a second one in background.
Update 3 :
my user pi as already pi ALL=(ALL) NOPASSWD: ALL
in the visudo file
sort.sh
doesn't run? Could you elaborate on that? Does the last statement, i.e.echo done
execute?"test.sh done!"
line will right now be written to the log directly aftertest.sh
has forked; not when the command is actually done. You should rather have a second line like:(sudo ./temp.sh "$1" "$2" "$3" && echo "test.sh done!") >>/home/pi/test.log &
. You still won't be able to provide credentials forsudo
non-interactively, so you will need to give the Deluge usersudo
privileges to executetest.sh
without password authentication for your attempt to work.sudo
configuration file via thevisudo
command. Read up on the syntax. There might also be annotated examples and further instructions in the file when it opens.