Scripting & sourced files in alpine...?

2 posts / 0 new
Last post
#1 Tue, 2017-06-13 14:55
martaver
  • martaver's picture
  • Offline
  • Last seen: 9 months 3 weeks ago
  • Joined: 2017-06-13

H everyone,

New to alpine & linux here, so apologies in advance if my question is blindingly obvious or stupid.

I'm having a lot of heartache trying to get anything meaningful scripted and running.

I know there's no bash, so I'm trying to write the script for sh - but basic things are escaping me. Can anyone answer a few Qs for me?

e.g. for a dir with contents & permissions like so...

/src/scripts # ls -l
total 9
-rwxr-xr-x    1 root     root           310 Jun 13 12:22 build.sh
-rwxr-xr-x    1 root     root          2871 Jun 13 12:08 deploy.sh
-rwxr-xr-x    1 root     root           451 Jun 13 12:08 env.sh
-rwxr-xr-x    1 root     root          1004 Jun  7 12:56 task-definition.json

I try to run a script, I get...

/src/scripts # ./build.sh
/bin/sh: ./build.sh: not found

Why? Shouldn't it run it under sh by default, anyway - no biggie...

So I explicitly invoke it with /bin/sh then it runs, but my '. sourced' script won't open...

/src/scripts # /bin/sh ./build.sh
Running build...
'/build.sh: .: line 3: can't open './env.sh

Source of build.sh looks like:

#!/bin/sh
echo 'Running build...'
. ./env.sh

env.sh is equally simple...

#!/bin/sh
 
# set environment variables to be used in build:
export IMAGE_NAME=my-image
export IMAGE_VERSION=latest

Try as I might I can't get shell to source the sibling script... I just get 'cant open'... I must be missing something really obvious.

Is it the path? permissions? I tried chmod a+x but no change... I've only used more full-featured distros so far, so I'm not sure what's missing.

Also can anyone recommend generally some resources for scripting in alpine? Is there any documentation for scripting syntax? Any helpful tools you recommend?

Appreciate any help...

Tue, 2017-06-13 17:43
martaver
  • martaver's picture
  • Offline
  • Last seen: 9 months 3 weeks ago
  • Joined: 2017-06-13

Problem was my scripts being created with CRLF endings... see I'm a reformed Windows user, and still have some dirty habits ;-)

Sorry to waste your time!

Log in or register to post comments