{ "{edition-$edition}" } gives "Undefined variable"

Any questions? Need some help?
Post Reply
tratento
Posts: 5
Joined: 10 Sep 2022, 01:41

{ "{edition-$edition}" } gives "Undefined variable"

Post by tratento »

Hi,

Trying to get the editions tag to work for Plex.

Code: Select all

FileBot 5.1.1 (r9982)
JNA Native: 6.1.4
MediaInfo: 22.06
Tools: NONE
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2024-05-12 (r962)
Groovy: 4.0.14
JRE: OpenJDK Runtime Environment 17.0.3
JVM: OpenJDK 64-Bit Server VM
CPU/MEM: 12 Core / 17 GB Max Memory / 49 MB Used Memory
OS: FreeBSD (amd64)
HW: FreeBSD torrent 13.1-RELEASE-p9 FreeBSD 13.1-RELEASE-p9 n245429-296d095698e TRUENAS  amd64
STORAGE: zfs [/] @ 222 GB
UID/GID: uid=0(root) gid=0(wheel) groups=0(wheel),5(operator)
DATA: /root/FileBot/data/0
Package: TAR
License: FileBot License P53472058 (Valid-Until: 2024-10-02)
Running the following:

Code: Select all

filebot -script fn:amc /var/db/qbittorrent/claim/Torrents/xHD/<XXX> --output /var/db/qbittorrent/claim/Torrents/zFilebot --action keeplink -non-strict --log-file /var/db/qbittorrent/claim/Torrents/zFilebot/amc.log --def excludeList=/var/db/qbittorrent/claim/Torrents/zFilebot/filebot-amc-exclude.txt movieFormat="/var/db/qbittorrent/claim/Movies/{ hd == /UHD/ ? 'UHD' : 'HD' }/{n} ({y})/{n} ({y} - {vf} - {vcf}.{acf} - {source} -{ n.findMatch(group) ? null : group })" { "{edition-$edition}" }
Gives:

Code: Select all

edition: Undefined variable.
When run via qBT and checking amc.log gives the following:

Code: Select all

...args[<X>] = movieFormat=/var/db/qbittorrent/claim/Movies/{ hd == /UHD/ ? 'UHD' : 'HD' }/{n} ({y})/{n} ({y} - {vf} - {vcf}.{acf} - {source} -{ n.findMatch(group) ? null : group }) { {edition-} }

... ...

Script Error: startup failed:
__script_fd684b1e73cf2b5ea528ccd9e2cbd85f_10: 1: Unexpected input: '{edition-}' @ line 1, column 10.
   {edition-}
            ^

1 error

Failure (×_×)⌒☆
How do I get it to stop treating "$edition" as a variable? or am I, once again, fundamentally misunderstanding something...

Thanks
User avatar
rednoah
The Source
Posts: 23143
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: { "{edition-$edition}" } gives "Undefined variable"

Post by rednoah »

:!: You are passing an invalid format, because the format you are actually passing is not the format you think you are passing, because bash is interpreting $variables inside "..." double-quoted strings, before calling filebot:
rednoah wrote: 14 Aug 2014, 10:02 $variables will be resolved:

Console Output: Select all

$ echo "I like $TEST"
I like


:arrow: Please read Cmdline and Argument Passing. If you're new to the command-line, then reading Cmdline and Argument Passing thoroughly will save you countless hours of trial and error.



:arrow: I strongly recommend reading complex custom formats from an external format file. Please read @file syntax for reading cmdline args from text files › Script Parameter Value and Automated Media Center › Troubleshooting for details.



:idea: If you're writing a bash script, then you'll want to start the script with the -u option to instruct to bash to error out when you accidentally use undefined bash variables:

Console Output: Select all

$ cat test.sh
#!/bin/sh -u
echo "{edition-$edition}"
$ ./script.sh
./script.sh: line 2: edition: unbound variable
:idea: Please read the FAQ and How to Request Help.
tratento
Posts: 5
Joined: 10 Sep 2022, 01:41

Re: { "{edition-$edition}" } gives "Undefined variable"

Post by tratento »

I appreciate the help, and the push to finally sit myself down and sort out using an external file for arguments.

Running great now
Post Reply