I am leaving this in order to follow up the original question which is asking to run a specific php script. But a workaround is provided in the New Recipe section in order to solve the main problem.
Please try this and inform on your results, after which this answer may be changed or deleted:
At a certain moment your password may be asked.
- First of all, let's create a file called script.php by dropping in a
terminal
sudo gedit script.php
(remember that you can drop this
file in whatever folder you wish but for testing purposes your home
folder will be good).
- In the file, let's copy/paste the contents of the script that you
mention. Save the file and close it down.
Now let's give the file the proper file permissions and the
execution permission also by dropping the next two lines in a
terminal, one line at once.
sudo chmod 755 script.php
sudo chmod a+x script.php
Now, let's install php5-cli by dropping in a terminal sudo apt-get
install php5-cli
and let's wait the terminal to finish the install
process.
Once php5-cli
is installed we can test the script by invoking php script.php --port=9999 --hostname=192.168.0.1;
in a terminal, but it will be better if you do it from inside of Transmission.
php5-cli is a command line interpreter for the PHP5 Scripting Language and it is useful to run php scripts like this, it is more like the php.exe file for Windows, the one that you refer on your original question.
I hope you succeed but please inform on your results in order to provide the proper support or delete this answer if not useful.
Addendum
After reading your comments, I give you this fast-food recipe for the php script.
First of all I need to explan certain things of the example given by the script's author, as follows:
script.php --port=9999 --hostname=192.168.0.1;
--port=9999
= 9999 is an example port, but in this field you should
write the same port number that you define on the Web client tab.
--hostname=192.168.0.1
= Must be the ip of the equipment that you wish the script run to kill transmission's process.
This makes me think that the process can be invoked remotely but for our particular case we are going to use the default values so that we need not to include neither the port nor the hostname. By simply running the script.php
file in a terminal or invoked by transmission and it's going to use the default values which apply to our computer (localhost
).
Then, let's cook fast food:
- We need a file, let's call it bye.sh and place it somewhere, your
home folder is a good place for testing purposes.
- Insert the next inside of the file (fast food script here),
save it, close it and give it execution permissions. (for reference,
go down on this answer and find how).
- Then, serve it inside of your Transmission "Download" tab but make
sure you include the proper bye.sh file to be invoked when the
download finishes.
That's it. I need to explain that somehow, the php script is succeeding but it observes a small delay after the downloads finishes and I have just tested with 2 small torrent files. I can't say if the delay will increase if the list is longer or the download size is heavier, behavior that is not observed by the New Recipe formula. However, the PHP file gives you the warranty that it's going to run in whatever OS that is PHP capable, and my New Recipe is mostly intended for Linux Based Systems, it works on Ubuntu and may succeed in other distributions, Debian or Ubuntu based, and certain modifications will allow it to succeed in other non Debian/Ubuntu based distributions.
Good luck!
New Recipe
OK I have a new recipe for this case, I admit it got all my attention, even when I don't use Transmission so often.
The Recipe
Ingredients
- transmission-gtk (installed somehow, from the software bag,
terminal, etc.)
- transmission-cli (sudo apt-get install transmission-cli, provide
password, wait the install to finish.)
- The Script. (cooked apart)
Preparation
- Let's prepare our transmission in order to receive web client
petitions from outside, this way we can monitor what is happening in
our program. Let's open Transmission and go to the "Web" tab in order
to enable the "Enable web client" checkbox as shown in the next
screenshot.
(Default values will do the trick perfectly)
- Let's open our favorite text editor in order to create a file named
byebye.sh
and let's place the next contents inside. (See the script here)
Now, let's find the bybye.sh file and give it the proper execution permissions by dropping in a terminal sudo chmod a+x bybye.sh
or by entering the file properties in Nautilus and activating the "Allow executing file as program" checkbox in the "Permissions" as shown in the next screenshot.
- Once we cooked out the script, let's install
transmission-cli
, in a
terminal drop: sudo apt-get install transmission-cli
, hit Enter and
provide your password, after which the software will be installed.
Time for tasting
In a terminal, drop transmission-remote --list | sed '1d;$d' | grep -v Done | wc -l
after which the results may vary from case to case, depending on the amount of torrents that are pending or currently downloading in transmission. If the results is different than 0
we're on our way. If you receive 0
and something is downloading or in queue, you must check the recipe from the beginning. If you receive an error please drop it in a comment in order to provide support.
- If everything is going fine, now let's instruct transmission to run
the script everytime a torrent is completed. CALM DOWN! Please,
calm... the script will run each time a torrent is completely
download, but it will only trigger the action to terminate
transmission just when the results of downloads equals zero. This
conditional way give us the tranquility that transmission won't close
down on each download. A screenshot is provided for your convenience:
And voila! The recipe can be served in generous portions and in company of all your downloads. Transmission will close down just if the last download succeeded.
SOME WARNINGS
If Transmission is having only one pending action and the download finishes at the very moment of the software's opening, Transmission is going to close as soon as it opens.
Glossary:
killall -9 transmission
= Will close transmission in a gently mode so that you won't receive an error message each time it is closed. By simply using killall transmission
is going to close it in an rude way thus the software will report a close failure.
Now, make sure you include a glass with excellent Cuban rum for me in the table when serving the recipe and...
Good luck!