How to run python script without arguments?

I was using Sonarr v2 and with “path” and “arguments” fields, my scripts runs ok.
Now, on version 3 beta without arguments field, I can’t make it run.
I’ve tried so many things, but it didin’t works at all.
I got this error

Invalid request Validation failed: 
-- : Script exited with code: 255

My script haven’t #! line. When I add, I got some others errors (can’t find path, file; errors 127, 2).
I think my problem is so simple, but I can’t figure out a solution.

Running latest V3 beta, on seedbox.

I’m poiting “path” directly to script, following: https://github.com/Sonarr/Sonarr/wiki/Custom-Post-Processing-Scripts

Create a .bat/.sh file with your Python location and script in. ie:

Path (on Sonarr): C:\plex_conversions\sickbeard_mp4_automator\sonarrv3.bat

Then in that .bat: "C:\Python3\python.exe" "C:\plex_conversions\sickbeard_mp4_automator\postSonarr.py"

Thanks for all those details.
I tried but it only runs via Gentoo ssh, when I execute on sonarr I receive the same error 255.

That’s my file call.sh
python /home/username/Archive/SubsSeries.py

Tried this and works also
/usr/bin/python /home/username/Archive/SubsSeries.py

My py file have shebang, but if I remove it works anyway.
#!/usr/bin/python

Followed all those guides

Have you set the script to handle env sonarr_eventtype=“test”?

Here you can view what I’m doing.
My logging trace: https://pastebin.com/81YufjBs
My script: https://pastebin.com/5Tczw6zx

All that my script do is copy all subtitles from torrent folder or subfolder and rename them with .pt.srt (language) or .pt.forced.srt to same folder of video.mkv file which sonarr copied.

EventType = environ.get('sonarr_eventtype')
#fileSubs.write("\nEventType: "+EventType)
#Event type: Download ##Download or Upgrade, same answer
if EventType == "Test":
    sys.exit("Test event ok")

But before the code reach this part, one file .txt should be created.
I also tested clean code only with creating txt

Shouldn’t that be just sys.exit() because putting a string in there basically returns error code 1.

Try:

EventType = environ.get('sonarr_eventtype')
#fileSubs.write("\nEventType: "+EventType)
#Event type: Download ##Download or Upgrade, same answer
if EventType == "Test":
    sys.exit(0)

Not working even doing this change.
I’ll try few things, see if there’s something with seedbox.
If I solve this, I’ll come back with the solution, else I’ll revert back to v2.
I appreciate both your helps.

I solved it.
Cause:

cowls
“I have seen this issue when creating scripts in Windows env and then porting over to run on a Unix environment.”

As we can see here: https://stackoverflow.com/questions/14219092/bash-script-and-bin-bashm-bad-interpreter-no-such-file-or-directory

But I followed the second answer:

Nivin V Joseph
Run following command in terminal

sed -i -e 's/\r$//' scriptname.sh

Then try

./scriptname.sh

It should work.

At the end:
That’s my file call.sh (which I pointed on “path” field sonarr v3

#!/bin/bash
#
python ~/Archive/SubsSeries.py

SubsSeries.py file didn’t have shebang, directly my code.

Everything works fine!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.