Page 1 of 1
How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 11:12 am
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!
Re: How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 11:46 am
by safihre
Is the script being run at all? You can see this is History.
Re: How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 12:15 pm
by redoXiD
Yes, after unpacking the script ran without any warnings or errors.
Re: How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 1:16 pm
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.
Re: How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 3:15 pm
by redoXiD
The output of the script is:
However, there is still no filelist.txt file in the downloaded folder.
Re: How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 3:51 pm
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).
This will allow you to evaluate $1.
Re: How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 3:55 pm
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
Re: How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 3:56 pm
by sander
OneCD wrote: ↑May 27th, 2022, 3:51 pm
$1 might be empty.
Oh, yes. Or spaces in $1 might cause problems
Re: How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 4:15 pm
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!
Re: How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 4:17 pm
by OneCD
Re: How to determine the execution directory of a post-processing script?
Posted: May 27th, 2022, 4:45 pm
by sander
hahahaha. nice