Exit Codes

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
bjd223
Posts: 8
Joined: 18 Oct 2017, 14:41

Exit Codes

Post by bjd223 »

Hello,

I am writing a powershell script and was curious if there is any documentation of filebots error codes? I am currently catching anything greater then 0 as an error, which works fine but I would like to define them further if there are other error codes besides 1. One is the only error I have generated in my testing but I assume there are others.

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

Re: Exit Codes

Post by rednoah »

FileBot will exit with 0 on success and 1 if something went wrong. If you get 1 then you maybe be able to find more information in the standard error output.
:idea: Please read the FAQ and How to Request Help.
bjd223
Posts: 8
Joined: 18 Oct 2017, 14:41

Re: Exit Codes

Post by bjd223 »

I understand, however if you look online people have received error code 5, so I assume there is a two through four also. Anyway I currently display the error code, and log the file bot error text, however I like to catch errors and display custom error messages in my scripts and applications I write.

Also depending on the error received sometimes programmatic actions can be taken to fix the issue and rerun the command.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exit Codes

Post by rednoah »

Nope, right now, in the code it's always either 0 or 1 when System.exit() is called. If java is not working for some reason, then the java command might give you different exist codes, or the script calling java/filebot/amc might give you different exist codes.
:idea: Please read the FAQ and How to Request Help.
bjd223
Posts: 8
Joined: 18 Oct 2017, 14:41

Re: Exit Codes

Post by bjd223 »

Ok thanks, it sounds like the developer is allowing error codes to bubble up to main. This is common I just wanted to make sure before finishing my script.

Currently there are 170+ java exit codes, so I'll take a quick look through those for ones I want to deal with and fix before re-running the command (like fixing folder permissions).

Not a huge deal, but currently java already has an exit code 1, so it is impossible to catch that specific error and fix it programmatically. Not sure what that error is, or if anyone would even want to do that.
pandiloko
Posts: 10
Joined: 09 Jan 2018, 23:00

Re: Exit Codes

Post by pandiloko »

Sorry for necrobump but can't find any more information on this topic other than this thread and other one where pretty much says the same. The thing is I do get some different exit codes and I would rather have some reliable information than try to figure it out myself by trial and error. E.g. 4 for file already exits and 100 for no files selected.

I'm using FileBot 4.8.5 (r6224) by the way.

Anyway keep up the good work and any help will be appreciated.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exit Codes

Post by rednoah »

4.8.5 introduces more fine-grained exit codes:
https://www.filebot.net/docs/api/src-ht ... tCode.html

But you still won't get error code for specific errors, like file not found, just general errors, so it's still 0 success, or not-0 for not success.


0 ... SUCCESS
1 ... COMMAND-LINE ERROR (bad command-line syntax, your bad, couldn't possibly work)
2 ... BAD LICENSE (no license or expired license, causing a failure)
3 ... FAILURE (script crashes due to error, something that could work, but doesn't, maybe due to network issues)
4 ... DIE (script aborts on purpose)
100 ... NOOP (script successfully did nothing)

:idea: Exit Codes 3 .. 5 effectively apply to filebot -script calls only and depend on what the script wants to do.
:idea: Please read the FAQ and How to Request Help.
pandiloko
Posts: 10
Joined: 09 Jan 2018, 23:00

Re: Exit Codes

Post by pandiloko »

Thanks! That helped me a lot. I really think it is a good idea to have different exit codes for different types of failures or behaviors as for example 4 could be considered as a succesful exit code i.e. file already exists or found in exclude list.

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

Re: Exit Codes

Post by rednoah »

Feel free to suggest additional exit code and use cases, with examples.

Fee people care about the exit code, so I can just do a best guess of what people might need.
:idea: Please read the FAQ and How to Request Help.
mccouch
Posts: 7
Joined: 16 Feb 2015, 12:30

Re: Exit Codes

Post by mccouch »

The exit code of 100 (NOOP) seems to be giving me a couple of issues. Specifically, I have the amc script running a couple of times a.day on a synology nas, through the system scheduler with the option to send me an email everytime an error occurs.

Since 4.8.5, every time it runs without any new files to operate on , I get an email saying something wrong happened, but when reading it I realise it just didnt have any files to act on.

Can I disable the 100 exit code through some setting? I get its intent, but for bash environment it's just being read as an error instead of 'nothing happened'.

Other alternative would be to just put some wrapper code around the calling of the script so that if filebot.exitcode =100, then wrapperscript.exitcode=0.

I would prefer to not have to do this though.just seems messy and obfuscating.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exit Codes

Post by rednoah »

Since you're using the Synology Scheduler, can't you just add exit 0 at the end of the scheduled script?
:idea: Please read the FAQ and How to Request Help.
mccouch
Posts: 7
Joined: 16 Feb 2015, 12:30

Re: Exit Codes

Post by mccouch »

I can, but I actually want to know when a legitimate problem happens, that's I had the 'email me on error' feature activated.

As I said, I can write a wrapper script that treats exit code 100 like exit 0, and that would solve my problem.

But unless I'm the only one running into this, I would say an option to disable exit code 100 would make more sense. Usually people want to know and log when it stumbled on something and fell over, not when it ran ok but there were no new files available.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exit Codes

Post by rednoah »

What's the command you're using in Scheduler? Are you using commands created by FileBot Node?

:idea: I'll treat exit code 100 as exit code 0 in the task script used by FileBot Node

:idea: Having an option on what exit codes FileBot (or rather the amc script) might use is strange. I'm not aware of any command-line tools having options to changing what exit codes are returned.
:idea: Please read the FAQ and How to Request Help.
mccouch
Posts: 7
Joined: 16 Feb 2015, 12:30

Re: Exit Codes

Post by mccouch »

rednoah wrote: 08 Apr 2019, 17:21 What's the command you're using in Scheduler? Are you using commands created by FileBot Node?
yep. See below. Only diference from usual is the 'send email when script terminates abnormally".

Code: Select all

 /usr/local/filebot-node/task 111111...
PS: thanks for the support!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exit Codes

Post by rednoah »

Alright, I see you're using FileBot Node. Future versions of the task script will return exit 0 if the filebot call returns exit 100.
:idea: Please read the FAQ and How to Request Help.
mccouch
Posts: 7
Joined: 16 Feb 2015, 12:30

Re: Exit Codes

Post by mccouch »

Perfect, thanks! And apologies if I 'unwarrantedly poked' your new & fancy exit codes! 😉

Should I do anything to update the AMC script or will filebot just download the most recent version in some days time/whenever it's ready?

Thank you once more!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Exit Codes

Post by rednoah »

Well, the changes affect only FileBot Node, and the FileBit Node specific task script will handle error codes so it works well with Synology Scheduler.

The amc script itself remains unaffected, for now, unless there's some good general unrelated to Synology reason to exit 0 for "did nothing but successfully so".


EDIT:

No FileBot Node release in the near future since there aren't any other changes that warrant a release. Maybe next month. Wait if something else comes up too in the meanwhile.
:idea: Please read the FAQ and How to Request Help.
Post Reply