skip to Main Content

A couple of questions related to .sh script file for Ubuntu.
the following is my script:

#!/bin/sh
source /opt/fslc-x11/2.2.1/environment-setup-armv7at2hf-neon-fslc-linux-gnueabi
echo "./make-image-header.sh psplash-poky.png POKY"
./make-image-header.sh psplash-poky.png POKY
echo "autoreconf -vfi"
autoreconf -vfi
echo "./configure --host=x86_64-linux"
./configure --host=x86_64-linux
echo "make"
make
echo "****************** psplash DONE ****************** "

My questions are:

  1. using every single instruction in linux terminal all is ok: how can set the environment inside a script?
  2. supposing my script is outside the current folder, what’s the right way to enter in a folder? I tried "cd" command as in terminal, but it doesn’t run.

2

Answers


  1. When you start your script, a new process is created that only inherits your environment. When it ends, it ends. Your current environment stays as it is.

    Instead, you can start your script like this:

    . script.sh

    The . will evaluate the script in the current environment, so it might be altered.

    Login or Signup to reply.
  2. You can check the current directory you are in with
    pwd. The current directory you will be in is not the directory of where the .sh file is, but the directory you are in when you start running it.

    Inside the bash script you can use cd for changing directory, and check with pwd where you are. I hope this helped.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search