Linux – How to launch a bash script in another one

bashlinuxraspberry pi

I'm trying to launch a script bash from another one using sudo.

Here is my first script

echo "" $1 $2 $3  >>/home/pi/test.log
sudo ./ "$1" "$2" "$3" >>/home/pi/test.log &
echo " done!" >>/home/pi/test.log

When I run

./ 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 and its make an echo in a second file


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

Best Answer

Try this:

cd "$(dirname "$0")"
# rest of script goes here
# ...