Running a bash script

Currently reading
Running a bash script


Bit Poster
Hi, this is my first post so apologies if it is in the wrong place. This seemed most appropriate. But please move if necessary.

I'm running DSM 5.2 5967 & its actually an XPENonolgy system (DSM loaded onto custom hardware) but as this is not an official Synology forum, I hope this fact doesn't matter.
I have Emby server installed & I'm trying to automate the downloading of movie trailers into my libraries. A user on the Emby forum has posted a great bash script to achieve this. Here's the script github
When I try to execute it it comes up with various syntax errors. I have installed the Windows Subsystem for Linux onto my desktop PC and successfully run the script from there. So the script is working under the right environment. I guess that it won't run from DSM as the shell is ash rather than bash.

Is there a way to overcome this and get DSM to run bash scripts?
Ultimately I would like to have this script run automatically using the task scheduler.


Giga Poster
Hi. Without knowing what the errors are then it’s a bit of a wild guess. You do have youtube-dl installed? And have configured your paths?


Bit Poster
Thanks for the reply.
I'll run it again later and post some of the errors. ( On the mobile at the moment)
FYI, I have got youtube-dl installed & configured it with my own API key and set the paths correctly.


Bit Poster
I've tried a few things out.
With simply adding my folder paths, API etc, i get this error.
nas> ash /volume1/Data/Scripts/
/volume1/Data/Scripts/ line 43: syntax error: unexpected "&"
Line 43 refers to the log files.
But I can run this same script from a bash session on the Windows Subsystem and the Emby forum has had others running Linux use the script succesfully.

If i comment out the log files section (lines 42-48)
I get
nas> ash /volume1/Data/Scripts/
/volume1/Data/Scripts/ line 73: syntax error: bad substitution
Line 73 is
for i in "${PATHS[@]}"
The log file section is important so I can see what has been missed.
But then the path substitution is something fundamental to the script completing.

Thanks in advance for anyone looking into this


Giga Poster
I don’t have a DSM 5.1 machine just 6.2, plus I’m ill so it’s as much as I can do for now.

I’d check if 5.1 has bash as it’s odd that the script invokes bash but the errors are ash. In 6.2 sh and ash commands are symbolic links to bash. Does 5.1 do it the other way round?

If true bash shell isn’t available then you’ll have to re-code the commands into ash. The best thing would be to Google ash script language vs bash.

I’d also check the contents of /bin for log command. I see logger but not log.


Bit Poster
Thanks for the response.
I'm not sure about the sym links for sh & ash between the two different DSM versions. But trying to Google how to change bash to ash commands was proving too advanced for my basic Linux skills.

I have installed a Debian docker image to try and run it through this instead. This may be a bit overkill just to execute one script, but the Debian image is pretty lightweight and only a 120MB download.
I've configured it to provide access to the relevant areas of the file system and installed the script dependencies.
Have performed a test run and it seems to be working OK.
Hopefully once I configure a cron job to run the script twice a day I should be all set.


NAS Support
DS412+, DS718+, DS918+, 2x RS3614RPxs+ with expansions
RT1900ac, RT2600ac, MR2200ac
Well done. Thinking outside the box

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Welcome to! is an unofficial Synology forum for NAS owners and enthusiasts.

Registration is free, easy and fast!