How do I get the script to work in Transmission (Filebot)

Ask for help and report issues with the Mac OS X version of Transmission
rajjejosefsson
Posts: 14
Joined: Wed Feb 26, 2014 7:14 am

How do I get the script to work in Transmission (Filebot)

Post by rajjejosefsson »

I am a beginner at this but will try to explain.

How to call 3rd party programs and how to pass in arguments?
Looks like Transmission is not setting environment variables correctly before the bash script is called which relies on them. (said by one on the forum on filebot)


here is the script i use http://www.filebot.net/forums/viewtopic.php?f=4&t=520

#!/bin/bash
/Applications/Filebot.app/Contents/MacOS/filebot -script fn:amc --output "path/to/folder" --log-file amc.log --action copy --conflict override -non-strict --def artwork=y "ut_dir=$TR_TORRENT_DIR/$TR_TORRENT_NAME" "ut_kind=multi" "ut_title=$TR_TORRENT_NAME"

it end up like this :

rasmusmcbookpro:~ Rasmusjosefsson$ /Users/Rasmusjosefsson/Documents/transmission-postprocess ; exit;
Locking /Users/Rasmusjosefsson/.filebot/logs/amc.log
Parameter: subtitles = en
Parameter: artwork = y
Parameter: ut_dir = /
Parameter: ut_kind = multi
Parameter: ut_title =
NullPointerException: java.lang.NullPointerException
java.lang.NullPointerException
at net.sourceforge.filebot.media.ReleaseInfo$FolderEntryFilter.accept(ReleaseInfo.java:351)
at net.sourceforge.filebot.media.MediaDetection.isDiskFolder(MediaDetection.java:86)
at net.sourceforge.filebot.media.MediaDetection$isDiskFolder.call(Unknown Source)
at Script2$_run_closure9.doCall(Script2.groovy:18)
at Script2$_run_closure9.doCall(Script2.groovy)
at Script3.resolveInput(Script3.groovy:71)
at Script3$_resolveInput_closure60.doCall(Script3.groovy:72)
at Script3.resolveInput(Script3.groovy:72)
at Script3.run(Script3.groovy:83)
at net.sourceforge.filebot.cli.ScriptShell.evaluate(ScriptShell.java:102)
at net.sourceforge.filebot.cli.ScriptShell.runScript(ScriptShell.java:95)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(ArgumentProcessor.java:125)
at net.sourceforge.filebot.Main.main(Main.java:190)
Failure (°_°)
logout

what i understand it shouldn't look like this -- > Parameter: ut_dir = /

Parameter: ut_dir = /

if $TR_TORRENT_DIR is empty something is wrong.
rajjejosefsson
Posts: 14
Joined: Wed Feb 26, 2014 7:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rajjejosefsson »

Comon anyone? sorry about double post.
rajjejosefsson
Posts: 14
Joined: Wed Feb 26, 2014 7:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rajjejosefsson »

2.82, do you have any idea?
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rb07 »

rajjejosefsson wrote:Looks like Transmission is not setting environment variables correctly before the bash script is called which relies on them. (said by one on the forum on filebot)
Wrong.

A lot of people use scripts with Transmission, and we don't have any problem like that, the variables are set.
rajjejosefsson wrote:if $TR_TORRENT_DIR is empty something is wrong.
Right.

It probably means that Transmission is not running the script (i.e. check your settings). Your log probably was produced by running the script manually.

A better log can be made by adding this to the top of the script:

Code: Select all

#!/bin/bash -x
#
# DEBUG
LOG=/tmp/$$.log
exec > $LOG 2>&1
rajjejosefsson
Posts: 14
Joined: Wed Feb 26, 2014 7:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rajjejosefsson »

Its says

Login User_Process 499 ttys000
Login Dead_Process: 499 ttys000

from the systemlog and the script manually pressed says



/Users/Rasmusjosefsson/Desktop/transmission-postprocesss ; exit;
+ LOG=/tmp/510.log
+ exec
logout

[Processen sucsess]
Last edited by rajjejosefsson on Fri Feb 28, 2014 10:44 pm, edited 1 time in total.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rb07 »

rajjejosefsson wrote:Its says
"It"? Am I supposed to guess what you are talking about?
rajjejosefsson wrote:the script manually pressed
Are you running scripts by double clicking on them?

Have you tried running them on a terminal?

Sorry I didn't realize this was on a Mac, I don't know what could be different there, but the last piece of what appears to be a log (the real log should be in /tmp/510.log as the output shows) doesn't have the running of the real command.
rajjejosefsson
Posts: 14
Joined: Wed Feb 26, 2014 7:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rajjejosefsson »

Don't know how to find .log if someone can guide me, I'm also new on mac but i think it will be in "system logs" but where
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rb07 »

You didn't answer any of my questions. That is rude.

You really should start by using the terminal.

The lines I suggested adding will make the bash script tell you what its doing (when you run it on a terminal -- Terminal.app in Mac speak), the log is going to change name each time you run the script, that's why your example showed "/tmp/510.log", the "510" comes from the process number, the file is exactly there "/tmp" means the tmp directory (from root)... You can change the location, it it makes it easier for you (using Finder).
rajjejosefsson
Posts: 14
Joined: Wed Feb 26, 2014 7:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rajjejosefsson »

Im only using terminal and did try what you said

1. cd desktop
2. nano transmission-postprocess
3.

#!/bin/bash -x
#
# DEBUG
LOG=/tmp/$$.log
exec > $LOG 2>&1
/Applications/Filebot.app/Contents/MacOS/filebot -script fn:amc --output "my/path" --log-file amc.log --action copy --conflict override -non-strict --def artwork=y "ut_dir=$TR_TORRENT_DIR/$TR_TORRENT_NAME" "ut_kind=multi" "ut_title=$TR_TORRENT_NAME"

then cmd + x thens YES
then enter and i've a file that i can click on desktop and that files open terminal and runs the script and says
Last edited by rajjejosefsson on Sun Mar 02, 2014 10:28 pm, edited 1 time in total.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rb07 »

You edited the script as UTF, change it to text (ASCII text). The quotes you see, are not quotes (") but the UTF equivalent (probably opening, and closing quotes), which is not valid as quotes on a script.
rajjejosefsson
Posts: 14
Joined: Wed Feb 26, 2014 7:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rajjejosefsson »

How do i change the format to ASCII?
Last edited by rajjejosefsson on Sun Mar 02, 2014 10:27 pm, edited 2 times in total.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rb07 »

rajjejosefsson wrote:How do i change the format to ASCII?
That depends on the editor you use.

I guess you're using TextEdit.app, then use "Save as...", and in the options change the format to "plain text"... if that is an option (I don't use Mac OSX), if not... you can do it on a terminal, with something like:

Code: Select all

iconv -f UTF-8 -t ASCII <file> > <new-file>
the parameters <file> and <new-file> are names you define, the from parameter (-f) I'm guessing from what you wrote (instead of a quote you show â, and \200\235), but I may be wrong, I didn't check if it is UTF-8 (and again, I don't use Mac OSX).
rajjejosefsson
Posts: 14
Joined: Wed Feb 26, 2014 7:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rajjejosefsson »

Im trying with textmate app and picked plain text and Western - Windows and copy and paste in terminal.
Last edited by rajjejosefsson on Sun Mar 02, 2014 10:26 pm, edited 1 time in total.
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rb07 »

rajjejosefsson wrote:picked plain text and Western - Windows and copy and paste in terminal
What?

I don't understand, but I'm sure "Western - Windows" is wrong.

Copy and paste what in terminal?

It looks like you're doing everything wrong. From the beginning:
  1. You have a bash script, we don't know its name, but it is a file.
  2. That file was edited with a word processor that instead of simple quotes used open-quote/close-quote. That is not valid for a script.
  3. To fix that you have to either save the file as plain text, that means no encoding (Western means ISO-8859-1, Windows means CP1250, we don't want those encodings).
  4. Don't run the script manually. We don't care to see that it doesn't work, because we already know its not going to work (i.e. its not the same as running from transmission, unless you know what you are doing, and also set the variables).
OK, that last one was just angry. If you want to really test the script on a terminal, then do it like this (assuming the bash script is named test.sh):

Code: Select all

TR_TORRENT_DIR=/somewhere/MyDownloads TR_TORRENT_NAME=MyTorrent ./test.sh
rajjejosefsson
Posts: 14
Joined: Wed Feb 26, 2014 7:14 am

Re: How do I get the script to work in Transmission (Filebot

Post by rajjejosefsson »

So I'm going to write it down in text document then what do i need to type by my self, what is variables? is it the TR_TORRENT_NAME or the quotes " and dollar mark $?

So I'm going to save it as .txt?

and then i understand I'm going to test it by
TR_TORRENT_DIR=/Users/Rasmusjosefsson/Desktop TR_TORRENT_NAME=MyTorrent ./test.sh

i have the file one the desktop named test

i typed in CD desktop in terminal then this TR_TORRENT_DIR=/Users/Rasmusjosefsson/Desktop TR_TORRENT_NAME=MyTorrent ./test.sh
but i says
-bash: ./test.sh: Permission denied

cd desktop (the files is there)
chmod +x test
Post Reply