Download scripts no longer running?

Ask for help and report issues with the Mac OS X version of Transmission
Post Reply
LividChihuahua
Posts: 6
Joined: Thu Oct 12, 2006 4:27 am

Download scripts no longer running?

Post by LividChihuahua »

I recently purchased a new mac and after setting up transmission I can no longer get it to run a script on download completion. I can run the script directly and it works as expected:

Code: Select all

#!/usr/local/bin/node
const fs = require('fs');
fs.writeFile('./torrent-mover-test.txt',JSON.stringify(process.env,null,4),function(err){
    if(err) {
        return console.log(err);
    }

    console.log("The file was saved!");
}); 
I checked the transmission log and see that it does call the script, however it does not create a file (unlike when you run it in terminal directly. I checked the permissions and gave it everything.

Code: Select all

-rwxrwxrwx@ 1 me  staff  237 Feb 24 15:52 torrent-mover.sh
I though that maybe I was going crazy so I searched around the forum and found the simplest test script possible in another thread.

Code: Select all

#!/bin/bash
echo "$TR_TORRENT_NAME is completed" >> ./test.log
Again, I see it called int he transmission log but it does not create a test.log file like it does when run from terminal directly. It too has the same permissions that the above script has. All attempts to search for this problem keep bringing me back to "give it execute permissions" but clearly it has all the permissions it could possibly need (and I even ran chmod a+x on it just in case).

Anybody have similar issues? I was wondering if it might be a Mojave thing but I imagine if that were the case it would be reported and probably even fixed by now (and I don't see a bunch of mentions in the forum or anything).
mike.dld
Transmission Developer
Posts: 306
Joined: Wed Dec 25, 2013 10:56 pm

Re: Download scripts no longer running?

Post by mike.dld »

Both of your test scripts are using relative paths to write to a file. One does not really know what Transmission's working directory (which is what those paths are relative to by default) would be upon script execution, and need to be explicit by providing full paths to files the script is working with, or changing the working directory so that it points to the path you expect. For instance, use "$(dirname "$0")/test.log" in your second example instead of "./test.log" if you want the file to appear in the same directory as the script itself, or do a `cd "$(dirname "$0")"` before using "./test.log" as is.
mike.dld
Transmission Developer
Posts: 306
Joined: Wed Dec 25, 2013 10:56 pm

Re: Download scripts no longer running?

Post by mike.dld »

And if you wonder what the working directory is for your script at any point, do `echo "$PWD" > /tmp/pwd.txt`, or `env > /tmp/pwd.txt` to see the whole environment.
LividChihuahua
Posts: 6
Joined: Thu Oct 12, 2006 4:27 am

Re: Download scripts no longer running?

Post by LividChihuahua »

Yup, that was it. Thanks.
Post Reply