log the command executed

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
marciton
Posts: 22
Joined: 11 Mar 2020, 23:39

log the command executed

Post by marciton »

Hi
in a bash script, I have:

Code: Select all

echo $run $new_directory2
$run $new_directory2
the result of the echo is:

Code: Select all

/usr/local/bin/filebot -rename --log all --log-file /var/services/homes/admin/log.txt --format "{n} - {s00e00} - {t}" --lang fr --db TheTVDB --q 'Miracle Workers (2019) 2019' -list --filter s==02/volume2/Downloads/_series/Miracle\ Workers\ \(2019\)/season\ 2/*.mkv
if I run this... it's working perfectly but the output of my script is ""-" is not a valid option"

So I guess something is missing somewhere...and I spent my sunday on it ... any clue?
is there a way to "log" the command that is really run to find the error?
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: log the command executed

Post by rednoah »

Well, there's clearly a space missing here:

Code: Select all

--filter s==02/volume2/Downloads/_series/Miracle\ Workers\ \(2019\)/season\ 2/*.mkv

:!: Please read Cmdline and Argument Passing for details.
:idea: Please read the FAQ and How to Request Help.
marciton
Posts: 22
Joined: 11 Mar 2020, 23:39

Re: log the command executed

Post by marciton »

correct ... unfortunately for me, just a copy past error here ... the space is there in the script ...
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: log the command executed

Post by rednoah »

If you need our help, please paste command and console output, verbatim, without errors. Otherwise, what's the point? Add additional screenshots if necessary. :lol:


Please read this thread from beginning to end, don't just skim it, to get a good feel for how command-line arguments work, and Troubleshooting advice:
rednoah wrote: 06 Apr 2020, 05:12 Please read Cmdline and Argument Passing for details.

A systematic way to approach the problem would work like this:

Code: Select all

$ filebot -script fn:sysenv
args[0] = -script
args[1] = fn:sysenv

Code: Select all

$ filebot -script fn:sysenv /usr/local/bin/filebot -rename --log all
args[0] = -script
args[1] = fn:sysenv
args[2] = /usr/local/bin/filebot
args[3] = -rename
args[4] = --log
args[5] = all
:arrow: The sysenv script just mirrors the arguments passed in, so we can see the arguments passed in. You just repeat this, adding one argument after another, until you find the one that doesn't work as expected. The cause will most likely be not escaped/quoted or badly escaped/quoted arguments.


:idea: Please read How to Request Help.
:idea: Please read the FAQ and How to Request Help.
marciton
Posts: 22
Joined: 11 Mar 2020, 23:39

Re: log the command executed

Post by marciton »

Thanks so it's could be related to the path..
how to you escape the space in the variable if it's not \

if I do:

MD="/usr/local/bin/filebot -script fn:sysenv -rename /volume2/Downloads/_series/HelloW/season\ 3/*.mkv"
$MD

it's doing:
File does not exist: /volume2/Downloads/_series/HelloW/season\
File does not exist: 3/*.mkv

Normal the path is "/volume2/Downloads/_series/HelloW/season 3/*.mkv"
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: log the command executed

Post by rednoah »

Wouldn't it be nice if someone had spent time and effort to write easy-to-understand help pages with lots of examples that specifically explain how the shell handles "" quotes and * shell expansion and the combination thereof? :lol:
rednoah wrote: 06 Apr 2020, 08:38 Please read this thread from beginning to end, don't just skim it, to get a good feel for how command-line arguments work, and Troubleshooting advice:
rednoah wrote: 06 Apr 2020, 05:12 Please read Cmdline and Argument Passing for details.
NO:

Code: Select all

filebot -script fn:sysenv "/path/to/Season 1/*.mkv"
NO:

Code: Select all

filebot -script fn:sysenv "/path/to/Season\ 1/*.mkv"
YES:

Code: Select all

filebot -script fn:sysenv /path/to/Season\ 3/*.mkv
YES:

Code: Select all

filebot -script fn:sysenv /path/to/Season" "3/*.mkv
YES:

Code: Select all

filebot -script fn:sysenv "/path/to/Season 3"/*.mkv
YES:

Code: Select all

filebot -script fn:sysenv "/path/to/Season 3/"*".mkv"
...
:idea: Please read the FAQ and How to Request Help.
marciton
Posts: 22
Joined: 11 Mar 2020, 23:39

Re: log the command executed

Post by marciton »

Ok, I tried hard ... without success ... I have reduce to 6 lines of code to debug ... what I'm missing there...?

I tired all previous syntax. it's working out of the script but not inside bash script...

Code: Select all

#!/bin/bash
export PATH="/usr/local/bin:$PATH"

MD="/usr/local/bin/filebot -script fn:sysenv -rename "/volume2/Downloads/_series/HelloW/season\ 3/*.mkv""
echo $MD
$MD

Post Reply