Parameters

Come up with a useful post-processing script? Share it here!
Post Reply
vertigo
Newbie
Newbie
Posts: 5
Joined: April 8th, 2019, 11:04 pm

Parameters

Post by vertigo »

I'm trying to make a script to run upon download completion to, depending on its location, either run a couple command lines on it then move it or run a single command line on it, but I made a test batch file to write the parameter and environmental parameters I might need to a text file to see what they are exactly, and I've tested it twice and they're all blank. For example, the first line is

Code: Select all

echo 1 - %1 >> file
and one of the environment variable lines is

Code: Select all

echo SAB_FINAL_NAME - %SAB_FINAL_NAME% >> file
and I even tried assigning them to variables first then echoing those. But I just get "1 - " and "SAB_FINAL_NAME - " in the file. What am I doing wrong?

Also, since it only runs on queue finish, and not after each download, does it keep track for each download and run it once for each one? Just seems like it would make more sense to do it after each individual download, especially since sometimes the queue doesn't finish for days if a bigger one is in it.

Of course, even if I get this working, it means it'll flash the command prompt window every time it runs, which I' prefer it didn't. I suspect that would be one of the benefits of a Python script, but I'm unfamiliar with that language. If someone could help write up a script to do what I need, it would be much appreciated.
User avatar
sander
Release Testers
Release Testers
Posts: 9079
Joined: January 22nd, 2008, 2:22 pm

Re: Parameters

Post by sander »

What do you get when you run it from the command line, with a few parameters to fill %1 etc?

With

Code: Select all

echo 1 - %1 >> hellothere-output.txt
it works:

Code: Select all

C:\tempie>testing.bat who is there

C:\tempie>echo 1 - who  1>>hellothere-output.txt

C:\tempie>
C:\tempie>type hellothere-output.txt
1 - ikke
1 - who

C:\tempie>
vertigo
Newbie
Newbie
Posts: 5
Joined: April 8th, 2019, 11:04 pm

Re: Parameters

Post by vertigo »

It works exactly as expected if I do that, both with and without quotes around the parameters. Basically, it looks like SAB isn't actually passing any parameters.
User avatar
sander
Release Testers
Release Testers
Posts: 9079
Joined: January 22nd, 2008, 2:22 pm

Re: Parameters

Post by sander »

Ah, I see.

What if you run Sample-PostProc (in C:\Program Files\SABnzbd\scripts) as post-processing script ... ?
vertigo
Newbie
Newbie
Posts: 5
Joined: April 8th, 2019, 11:04 pm

Re: Parameters

Post by vertigo »

I tried it but it didn't run AFAICT. I added a pause at the end to keep the window open, but when the queue finished, no window opened.
User avatar
sander
Release Testers
Release Testers
Posts: 9079
Joined: January 22nd, 2008, 2:22 pm

Re: Parameters

Post by sander »

The output of that script should be in the drop-down of your download in Sab
vertigo
Newbie
Newbie
Posts: 5
Joined: April 8th, 2019, 11:04 pm

Re: Parameters

Post by vertigo »

That's what I thought, but there's nothing there either. I checked the log file and it says it ran the script, but aside from that there's no evidence that it actually did. I know it can run them, since mine ran, so I'm not sure what the deal is.
vertigo
Newbie
Newbie
Posts: 5
Joined: April 8th, 2019, 11:04 pm

Re: Parameters

Post by vertigo »

Well, I did some more testing and verified that the scripts were in fact running, so then I tried setting the download itself to run the script instead of setting the script to run on queue completion, and that made it work as expected. While this isn't terribly surprising, since, as I mentioned before, it didn't make sense that it would be able to assign different values for the parameters for multiple items, it is something that really should be mentioned in the instructions for using scripts. In fact, not only do the instructions not even mention how to run a script at all (I had to search to figure out where to select them to run, as I assumed based on the instructions that any script in the scripts folder would just automatically run), but it also took me quite a while to even find the instructions, since I spent easily several minutes digging through the settings, over and over, looking for an option in there. There should be a link to the instructions next to the script folder setting.

Anyways, now that I have that figured out, I'll have to do some more testing, but hopefully I'll finally be able to get it to do what I need, though I'll still have the issue of having the window pop up.
Post Reply