user script that calls other scripts failing

Come up with a useful post-processing script? Share it here!
Post Reply
capslock118
Newbie
Newbie
Posts: 2
Joined: May 2nd, 2013, 9:05 pm

user script that calls other scripts failing

Post by capslock118 »

This page provided useful info:
https://forums.sabnzbd.org/viewtopic.php?f=9&t=6203

My post-processing user script fails and I'm not quite confident as to why. I've echoed the values that sabnzbd should be passing to make sure they are there, and sure enough they are. Any help would be appreciated.

Just for background, sabToSickBeard.py is provided by sickbeard and sabToPushover is a script based on a pushover script I found on this forum:
https://forums.sabnzbd.org/viewtopic.ph ... 377#p73377. Both scripts work if called by sabnzbd directly.

Here is my post-processing script:

Code: Select all

#!/usr/bin/env bash
python /usr/local/sickbeard/autoProcessTV/sabToPushover.py $1 $2 $3 $4 $5 $6 $7
python /usr/local/sickbeard/autoProcessTV/sabToSickBeard.py $1 $2 $3 $4 $5 $6 $7

echo $0
echo $1
echo $2
echo $3
echo $4
echo $5
echo $6
echo $7

Here is the result:
Traceback (most recent call last):
File "/usr/local/sickbeard/autoProcessTV/sabToPushover.py", line 8, in <module>
print("Convertig argument " + sys.argv[7] + " to status.")
IndexError: list index out of range
Traceback (most recent call last):
File "/usr/local/sickbeard/autoProcessTV/sabToSickBeard.py", line 25, in <module>
if sys.argv[7] == 0:
IndexError: list index out of range
/usr/local/sickbeard/autoProcessTV/groupProcessing.py
/folder_location/filename.3
filename.nzb
filename

tv
alt.binaries.teevee
3
User avatar
jcfp
Release Testers
Release Testers
Posts: 1022
Joined: February 7th, 2008, 12:45 pm

Re: user script that calls other scripts failing

Post by jcfp »

All the necessary quoting is missing, that's asking for trouble. Also, if you just want to pass all argument received by the parent script it's easier to use "$@" instead of listing each one.
capslock118
Newbie
Newbie
Posts: 2
Joined: May 2nd, 2013, 9:05 pm

Re: user script that calls other scripts failing

Post by capslock118 »

jcfp thanks for your quick and awesome reply. I didn't know about $@, that will be very helpful in the future.

The script is working now as I had hoped and I understand exactly what happened now.

When I read the user script wiki here: http://wiki.sabnzbd.org/user-scripts I made a lazy assumption that I didn't have to worry about quoting the parameters:
All parameters are properly quoted so that they may contain embedded spaces.
I assumed incorrectly that this meant the quoted strings carried forward.

Thanks again for your help!
User avatar
jcfp
Release Testers
Release Testers
Posts: 1022
Joined: February 7th, 2008, 12:45 pm

Re: user script that calls other scripts failing

Post by jcfp »

Good to hear stuff is working. Suggestions for wiki improvements are welcome in this topic.
Post Reply