Find the answer to your Linux question:
Results 1 to 6 of 6
Here's the scenario: In my /home/ATS/Build_4_1 directory I have a bash script that sets up some mission variables (I'm a NASA developer). In the /home/ATS/Build_4_1/build/rad750 directory I have a bash ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2012
    Posts
    2

    Bash scripting problem


    Here's the scenario:

    In my /home/ATS/Build_4_1 directory I have a bash script that sets up some mission variables (I'm a NASA developer). In the /home/ATS/Build_4_1/build/rad750 directory I have a bash script that does a make clean/make all/make install for the flight software. There is also a script in the /opt/WindRiver directory that sets some environment variables. Running each script with source works just fine. What I need to do is to be able to run a single script that will call each of these three scripts which obviously have to be sourced to persist the variables. I've tried a script that looks like this:

    #!/bin/bash
    cd /opt/WindRiver;<run script>
    cd /home/ATS/Build_4_1;source <script>
    cd /home/ATS/Build_4_1/build/rad750;source <script>

    For some reason it doesn't get past the first call. Any Ideas?

    Thanks

  2. #2
    Linux Newbie
    Join Date
    Oct 2008
    Posts
    151
    How are you trying to run the first script? CDing each time is an unecessary step, you could run each script from one location, although the time savings would be minimal.
    How about

    Code:
    #!/bin/bash -x
     ./opt/WindRiver/scriptname
     ./home/ATS/Build_4_1/scriptname
     ./home/ATS/Build_4_1/build/rad750/scriptname
    exit
    Edit: The first one is executable, yes?
    Last edited by kurtdriver; 03-02-2012 at 11:37 PM.

  3. #3
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    664
    When debugging bash scripts, I use this at the top of the script:
    set -x
    exec 2>/tmp/outfile$$
    That will produce a script trace in /tmp/outfile<pid of process>. I'd do it in the wrapper first, to see if it's getting to the second script at all, then proceed to the other scripts to see if I could spot where the bailout happens.

  4. #4
    Just Joined!
    Join Date
    Mar 2012
    Posts
    2
    Thanks for the replies. I tried as you suggested:

    #!/bin/bash -e

    ./home/ATS/gpm_gcc_3_4_4_env.sh
    ./home/ATS/Build_4_1/setvars.sh
    ./home/Build_4_1/build/rad750/build.sh

    with the following output:

    ./home/ATS/gpm_gcc_3_4_4_env.sh
    line 3: ./home/ATS/gpm_gcc_3_4_4_env.sh: no such file or directory

    The same output for the other two lines of the script. Am I missing something here?

    Thanks

  5. #5
    Just Joined!
    Join Date
    Jan 2011
    Location
    Hyderabad, India
    Posts
    24
    Quote Originally Posted by ozziehome View Post
    Thanks for the replies. I tried as you suggested:

    #!/bin/bash -e

    ./home/ATS/gpm_gcc_3_4_4_env.sh
    ./home/ATS/Build_4_1/setvars.sh
    ./home/Build_4_1/build/rad750/build.sh

    with the following output:

    ./home/ATS/gpm_gcc_3_4_4_env.sh
    line 3: ./home/ATS/gpm_gcc_3_4_4_env.sh: no such file or directory

    The same output for the other two lines of the script. Am I missing something here?

    Thanks


    You didn't provided the absolute path .....

    check whether file exist's there

  6. #6
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    664
    He means that the leading "." is turning your absolute paths into relative ones. Kurtdriver may have intended that there be a space after the dot, which amounts to sourcing each script using its absolute path.

    Code:
    #!/bin/bash -e
    . /home/ATS/gpm_gcc_3_4_4_env.sh
    . /home/ATS/Build_4_1/setvars.sh
    . /home/Build_4_1/build/rad750/build.sh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •