[BASH][SOLVED] probleme running multiple script

Come up with a useful post-processing script? Share it here!
Post Reply
Eelisland
Newbie
Newbie
Posts: 13
Joined: September 2nd, 2013, 1:51 pm
Location: France

[BASH][SOLVED] probleme running multiple script

Post by Eelisland »

Hello,

First of all, many thanks for SABnzbd, it brings newsgroup to the top ! :)

I have two scripts and want to run the two script in the default folder

ClamAV antivirus scan:

Code: Select all

#!/bin/sh

BASENAME=`basename "$1"`
LOGFILE="$1/clamscan.log"

/usr/bin/clamscan -i -l "$LOGFILE" -r "$1"

if [ $? -eq 1 ]; then
  cd "$1"/..
  mv "$BASENAME" _INFECTED_"$BASENAME"
  echo "Virus détecté!"
else
  echo "Pas de virus détecté."
fi
A script to check if there is a BDMV folder and use MkvMerge to convert the biggest M2TS file to MKV whithout compression:

Code: Select all

#!/bin/bash
BDMV_FOLD=`find "$1" -name "BDMV" -print0`

if [[ $BDMV_FOLD == *BDMV* ]]; then
   # cd to the ./BDMV/STREAM folder
   cd "$1"/BDMV/STREAM/
   # Find the biggest .M2TS file, usually the movie
   BIGST_M2TS=`find . -type f | xargs ls -1S | head -n 1 | rev | cut -c 6- | rev`
   # MkvMerge the file
   mkvmerge -o "$BIGST_M2TS".mkv --compression -1:none "$BIGST_M2TS".m2ts
   # Change MKV permission to -rw-r--r--
   chmod 644 "$BIGST_M2TS".mkv
   echo "Blu-Ray: MKV created!"
else
   echo "BDMV2MKV: no processing"
fi
Thoses two script work fine alone, when i call it from this one:

Code: Select all

#!/bin/bash
cd /home/toto/.sabnzb-script/
./ClamAV
./BDMV2Mkv
I get the following error:
ERROR: Problem with internal logger.
ERROR: Can't open /clamscan.log in append mode (check permissions!).
Pas de virus détecté.
find: `': No such file or directory
BDMV2MKV: no processing
The ClamAV script when used alone return(log file created fine):
----------- SCAN SUMMARY -----------
Known viruses: 3149659
Engine version: 0.97.8
Scanned directories: 1
Scanned files: 2
Infected files: 0
Data scanned: 0.00 MB
Data read: 95.37 MB (ratio 0.00:1)
Time: 5.836 sec (0 m 5 s)
Pas de virus détecté.
The BDMV To MKV script alone:
BDMV2MKV: no processing
Systeme is Slackware 14 - 64b Multilib, SABnzbd Version: 0.7.14:
toto 4160 0.6 2.7 2651292 221372 ? Sl Aug29 39:27 /usr/bin/python /usr/share/sabnzb/SABnzbd.py -d --browser 0
Note that i'm a complete noob in bash script, any help appreciated.

Regards.
Last edited by Eelisland on September 3rd, 2013, 7:31 am, edited 1 time in total.
Eelisland
Newbie
Newbie
Posts: 13
Joined: September 2nd, 2013, 1:51 pm
Location: France

Re: [BASH] probleme running multiple script

Post by Eelisland »

I get exactly the same error when running the script alone from the console, scripts don't receive $1,$2,$3 from SABNZBD when called by a script and not SABNZBD properly, any idea ? :)

Code: Select all

bash-4.2$ cd /home/toto/.sabnzb-script
bash-4.2$ ./multi_scripts
ERROR: Can't open /clamscan.log in append mode (check permissions!).
ERROR: Problem with internal logger.
Pas de virus détecté.
find: `': No such file or directory
BDMV2MKV: no processing
Regards.
User avatar
jcfp
Release Testers
Release Testers
Posts: 1004
Joined: February 7th, 2008, 12:45 pm

Re: [BASH] probleme running multiple script

Post by jcfp »

Code: Select all

#!/bin/sh

# either pass all arguments along
/run/this/script "$@"
/run/this/script2 "$@"

# or source the other script(s) into the one run by sab - the space after the dot is not a typo
. /run/this/script
. /run/this/script2
Eelisland
Newbie
Newbie
Posts: 13
Joined: September 2nd, 2013, 1:51 pm
Location: France

Re: [BASH] probleme running multiple script

Post by Eelisland »

Hi Jcfp,

Thx for your feedback!

Code: Select all

# or source the other script(s) into the one run by sab - the space after the dot is not a typo
. /run/this/script
. /run/this/script2
the space after the dot is not a typo

Work perfectly. thread SOLVED ;)
Post Reply