Howto launch a bash script

Ask for help about FlashGot, no registration needed to post
Post Reply
User avatar
Blinkiz
Posts: 3
Joined: Sat Aug 08, 2009 8:47 am
Location: Stockholm, Sweden

Howto launch a bash script

Post 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?
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: Howto launch a bash script

Post 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.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)
User avatar
Blinkiz
Posts: 3
Joined: Sat Aug 08, 2009 8:47 am
Location: Stockholm, Sweden

Re: Howto launch a bash script

Post 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?
Last edited by Blinkiz on Sat Aug 08, 2009 2:56 pm, edited 1 time in total.
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: Howto launch a bash script

Post 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.
Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 (.NET CLR 3.5.30729)
User avatar
Blinkiz
Posts: 3
Joined: Sat Aug 08, 2009 8:47 am
Location: Stockholm, Sweden

Re: Howto launch a bash script

Post 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. :)
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Post Reply