How to determine the execution directory of a post-processing script?

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
redoXiD
Newbie
Newbie
Posts: 6
Joined: May 27th, 2022, 10:54 am

How to determine the execution directory of a post-processing script?

Post by redoXiD »

Hi there,

I'm currently trying to create a post-processing script that creates a filelist in the downloaded folder. SABnzbd is currently running on my QNAP NAS.

The script I tried looks like this:

Code: Select all

#!/bin/bash

cd $1

ls -A -R -g -p --group-directories-first > filelist.txt
However, after successfully running the script, the filelist.txt doesn't appear in the folder that theoretically should have been chosen using "cd $1".

What am I doing wrong? I am very new to Linux, so any help would be appreciated!
User avatar
safihre
Administrator
Administrator
Posts: 5338
Joined: April 30th, 2015, 7:35 am
Contact:

Re: How to determine the execution directory of a post-processing script?

Post by safihre »

Is the script being run at all? You can see this is History.
If you like our support, check our special newsserver deal or donate at: https://sabnzbd.org/donate
redoXiD
Newbie
Newbie
Posts: 6
Joined: May 27th, 2022, 10:54 am

Re: How to determine the execution directory of a post-processing script?

Post by redoXiD »

Yes, after unpacking the script ran without any warnings or errors.
User avatar
sander
Release Testers
Release Testers
Posts: 8812
Joined: January 22nd, 2008, 2:22 pm

Re: How to determine the execution directory of a post-processing script?

Post by sander »

change the script to this:

Code: Select all

#!/bin/bash
echo Start
cd $1
echo Step2
ls -A -R -g -p --group-directories-first > filelist.txt
echo Done
... download something ... what is the output in SABnzbd ... ? Post it here.
redoXiD
Newbie
Newbie
Posts: 6
Joined: May 27th, 2022, 10:54 am

Re: How to determine the execution directory of a post-processing script?

Post by redoXiD »

The output of the script is:

Code: Select all

Start
Step2
Done
However, there is still no filelist.txt file in the downloaded folder.
User avatar
OneCD
Hero Member
Hero Member
Posts: 557
Joined: March 4th, 2017, 3:47 pm

Re: How to determine the execution directory of a post-processing script?

Post by OneCD »

$1 might be empty.

For testing purposes, add a line that sends $1 to stdout (which will be shown in the SABnzbd log).

Code: Select all

echo "\$1: [$1]"
This will allow you to evaluate $1.
Stuff I like: Apache bash cron DD-WRT Debian DNSMasq Entware FireFox GitHub ImageMagick Kate KDE LibreELEC Netrunner NFS NVIDIA OpenVPN Orvibo-S20 pfSense Python Raspberry-Pi RAID SABnzbd Transmission Usenet VirtualBox Watcher3 XFCE
User avatar
sander
Release Testers
Release Testers
Posts: 8812
Joined: January 22nd, 2008, 2:22 pm

Re: How to determine the execution directory of a post-processing script?

Post by sander »

So it runs, and completes. Good.

Before the "echo Done", you can put in:

ls filelist.txt

... to see if it's there at all.

It could be rights problems: the user running the script not allowed or able to write the file $1/filelist.txt
User avatar
sander
Release Testers
Release Testers
Posts: 8812
Joined: January 22nd, 2008, 2:22 pm

Re: How to determine the execution directory of a post-processing script?

Post by sander »

OneCD wrote: May 27th, 2022, 3:51 pm $1 might be empty.
Oh, yes. Or spaces in $1 might cause problems
redoXiD
Newbie
Newbie
Posts: 6
Joined: May 27th, 2022, 10:54 am

Re: How to determine the execution directory of a post-processing script?

Post by redoXiD »

$1 might be empty.

For testing purposes, add a line that sends $1 to stdout (which will be shown in the SABnzbd log).
I tried this, everything looks normal in this line. But looking through the log file, I discovered another interesting thing (shame on me... :-[ ):

Code: Select all

2022-05-27 20:58:03,871::INFO::[postproc:1064] Removing unwanted file /share/CACHEDEV1_DATA/Download/test/test_download_100MB.1/filelist.txt
As it turned out, unwanted files are removed after running the post-processing script (other than expected). Now that I unchecked txt files, everything works!
User avatar
OneCD
Hero Member
Hero Member
Posts: 557
Joined: March 4th, 2017, 3:47 pm

Re: How to determine the execution directory of a post-processing script?

Post by OneCD »

;D
Stuff I like: Apache bash cron DD-WRT Debian DNSMasq Entware FireFox GitHub ImageMagick Kate KDE LibreELEC Netrunner NFS NVIDIA OpenVPN Orvibo-S20 pfSense Python Raspberry-Pi RAID SABnzbd Transmission Usenet VirtualBox Watcher3 XFCE
User avatar
sander
Release Testers
Release Testers
Posts: 8812
Joined: January 22nd, 2008, 2:22 pm

Re: How to determine the execution directory of a post-processing script?

Post by sander »

hahahaha. nice
Post Reply