How to make "script-torrent-done-filename" working in windows

Ask for help and report issues with the Windows version of Transmission
karthik
Posts: 8
Joined: Mon Nov 20, 2017 3:55 pm

How to make "script-torrent-done-filename" working in windows

Postby karthik » Mon Nov 20, 2017 4:27 pm

Hi,

i am using transmission daemon in windows 10, i want to run a batch file after the torrent completes
Below is a snippet from my settings file. But this batch script is not getting executed

Code: Select all

"script-torrent-done-enabled": true,
"script-torrent-done-filename": "C:\\Users\\ishaan\\AppData\\Local\\transmission-daemon\\test.bat",


For testing i kept a simple batch script with a single line as shown below. It just creates a file 1.txt with text as 'test'

Code: Select all

echo 'test' > 1.xt


But the script is not running. I thought it could be permission issue, so i gave full permission to "Everyone" to execute the script
but still not working. I even tried setting "LogOn" user for daemon service to have admin user. But still not working

can you please help me in this

mike.dld
Transmission Developer
Posts: 249
Joined: Wed Dec 25, 2013 10:56 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby mike.dld » Mon Nov 20, 2017 4:42 pm

First, try specifying the full path instead of "1.txt" in your script, or do an explicit "cd ..." first. I'm not sure where exactly you expect this file to end up, but generally I'd say that current working directory upon script execution is unspecified (i.e. could be anything, including what you expect and don't expect).

Second, IIRC the set of environment variables during script execution is quite limited (mainly for security reasons), so if you're using a command that usually is in your %PATH%, check twice just in case by e.g. adding "set > C:\2.txt" in your script.

If neither helps, we'll think of something else :)

karthik
Posts: 8
Joined: Mon Nov 20, 2017 3:55 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby karthik » Mon Nov 20, 2017 5:43 pm

Hi Mike,

Thanks for the reply. My final goal is to run a python script from batch file. But before going that far i want to see if my simple batch file runs or not

I have modified the bat file as below with full path of the file

Code: Select all

echo 'teste' > C:\\Users\\ishaan\\AppData\\Local\\transmission-daemon\\1.txt

But unfortunately it is not working.

when i run this bat file externally from command prompt anywhere irrespective of working dir, it creates the file 1.txt
But when transmission daemon completes downlaod nothing happens :(

mike.dld
Transmission Developer
Posts: 249
Joined: Wed Dec 25, 2013 10:56 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby mike.dld » Tue Nov 21, 2017 8:40 am

Okay. I checked the code and it appears that it never worked. With batch files, that is. Since you want to run a python script in the end, please try a tool like py2exe to create an executable from the python script and use that in Transmission settings instead.

Meanwhile, I'm working on remediating batch files support.

karthik
Posts: 8
Joined: Mon Nov 20, 2017 3:55 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby karthik » Wed Nov 22, 2017 3:08 am

Thanks Mike. I will try to create an exe file from a simple c++ program and use its path in the settings file
i will try this today and let you know if it works

kenmex
Posts: 1
Joined: Wed Nov 22, 2017 8:17 am

Re: How to make "script-torrent-done-filename" working in windows

Postby kenmex » Wed Nov 22, 2017 8:19 am

Hi,

I tested an .exe generated from a python script, it seems like it is still not working

karthik
Posts: 8
Joined: Mon Nov 20, 2017 3:55 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby karthik » Wed Nov 22, 2017 1:16 pm

yes for me too. I also tried with an exe created from python file but it is not working
I also tried to use an exe built from a simple cpp file. That is also not working
is this the right way to give exe file path?

Code: Select all

"script-torrent-done-enabled": true,
"script-torrent-done-filename": "C:\\Users\\ishaan\\AppData\\Local\\transmission-daemon\\tp.exe"

mike.dld
Transmission Developer
Posts: 249
Joined: Wed Dec 25, 2013 10:56 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby mike.dld » Wed Nov 22, 2017 4:27 pm

Ugh... The setting values seem to be correct. Are you guys absolutely positive you're editing the correct settings.json file (just in case)? I.e. when the daemon is running, does executing `transmission-remote -si` print the same directory in "Configuration directory:" line of "CONFIG" section? I'll try to debug this in a few hours (I seem recall the script working at some point).

karthik
Posts: 8
Joined: Mon Nov 20, 2017 3:55 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby karthik » Thu Nov 23, 2017 6:42 am

I have used the correct config directory of transmission my other settings are getting picked up correctly

mike.dld
Transmission Developer
Posts: 249
Joined: Wed Dec 25, 2013 10:56 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby mike.dld » Thu Nov 23, 2017 7:52 am

I've tried it and the .exe script is getting executed just fine. I've used this simple C program to test it:

Code: Select all

#include <stdio.h>

int main()
{
    FILE* f = fopen("C:\\test.txt", "a");
    fprintf(f, "test\n");
    fclose(f);
    return 0;
}

The file gets created and "test" line gets appended to it on each script execution. Tested with both released 2.92 and latest nightly build, using both the Qt clent and the daemon.

mike.dld
Transmission Developer
Posts: 249
Joined: Wed Dec 25, 2013 10:56 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby mike.dld » Thu Nov 23, 2017 7:57 am

Are you guys editing settings.json directly (and not connecting to the daemon with Qt client)? In this case, are you stopping the daemon before making changes to the file and starting it aftewards, or at least executing `sc control transmission paramchange` after you change the file?

karthik
Posts: 8
Joined: Mon Nov 20, 2017 3:55 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby karthik » Thu Nov 23, 2017 8:07 am

I stopped transmission service and then edited the settings.. And then started the transmission daemon again..

karthik
Posts: 8
Joined: Mon Nov 20, 2017 3:55 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby karthik » Thu Nov 23, 2017 8:42 am

When will this script gets executed? When the download completes 100% or when I pause the download after it completed 100%

mike.dld
Transmission Developer
Posts: 249
Joined: Wed Dec 25, 2013 10:56 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby mike.dld » Thu Nov 23, 2017 9:23 am

The script is executed right after the download is finished.

You could try setting up logging to get more details. For that, execute the following command (replacing paths with those on your system) as administrator:

Code: Select all

sc config transmission binPath= "\"C:\Program Files\Transmission\transmission-daemon.exe\" --logfile C:\Temp\daemon.log"

Note that the path to the log file should be writable by the user the daemon is running under; e.g. I wasn't able to specify "C:\daemon.log" with default settings (log file wasn't created), but creating a "C:\Temp" directory with appropriate rights and using it helped.

karthik
Posts: 8
Joined: Mon Nov 20, 2017 3:55 pm

Re: How to make "script-torrent-done-filename" working in windows

Postby karthik » Thu Nov 23, 2017 1:11 pm

wow... somehow after setting the logfile as you have suggested my script got executed and a nice logfile also got generated.
Thankyou so much for your time :D :D :D


Return to “Windows Support”