Page 1 of 1

Howto launch a bash script

Posted: Sat Aug 08, 2009 8:58 am
by Blinkiz
Trying to pass a "URL list file" [UFILE] to my downloader.sh script here in Linux. Can't get it to work.

downloader.sh

Code: Select all

#!/bin/bash
echo "Got a hit" >> file.txt
In Flashgot log file, I can see this line:

Code: Select all

Running /home/blinkiz/Downloads/downloader.sh /tmp/flashgot.qftmjuin.default/flashgot-7.fgt -- async
Nice, but heay, nothing is happening! Running the above command in a terminal, and it works just fine.

What am I doing wrong here?

Re: Howto launch a bash script

Posted: Sat Aug 08, 2009 9:06 am
by Giorgio Maone
Firefox (and therefore FlashGot) can't run shell scripts directly, only native executables.
Therefore you need to specifiy the shell path itself as the executable (e.g. /bin/bash) and put your script's path as the 1st item of your arguments template.

Re: Howto launch a bash script

Posted: Sat Aug 08, 2009 2:19 pm
by Blinkiz
Okay,
In Flashgot, I now have /bin/bash as executable path. As comment line arguments, I have /home/blinkiz/Downloads/downloader.sh [UFILE].
This works. Problem is that it does not always works.

Starting Firefox-3.5 from gnome-terminal, Flashgot is executing /bin/bash.
Starting Firefox-3.5 from gnome start menu, Flashgot does not execute /bin/bash.
Why?

Re: Howto launch a bash script

Posted: Sat Aug 08, 2009 3:44 pm
by Giorgio Maone
Are you sure your script is not executed?
I suspect it's just a working directory issue: where do you expect the file.txt file to be created?
Please try to change your script as follow:

Code: Select all

#!/bin/bash
DIR=$(dirname $0)
echo "Got hit" > $DIR/file.txt
so that your test file is always created in the same directory as your script, rather than, for instance, inside your Firefox profile.

Re: Howto launch a bash script

Posted: Sat Aug 08, 2009 3:50 pm
by Blinkiz
As you said, it was a working directory issue.
Thanks for helping me out. Hopefully this forum topic can be of help to others trying to get theirs script to work. :)