1

I am trying to call a script using another script located in a different directory but some errors(related to the location of the file) appear. To ilustrate my problem, I will show an example.

Imagine that I have a folder called 001, and inside the folder has another 3 subfolders called A , B and C. Furthermore, inside the folder 001 there are a script called script. In each subfolder A, B and C I has the files lista, listb and listc respectively

When I execute the script, the output are printed and every is OK. But I am interested to call this script using the motherscript, but I get the error.

cat: A/lista: No such file or directory
cat: B/listb: No such file or directory
cat: C/listc: No such file or directory

Ilustration of directories

   folder
     |_ motherscript
     |_ 001
         |_ A
         |   |_lista
         |_ B
         |   |_listb
         |_ C
         |   |_listc
         |_ script 

script

 cat A/lista B/listb C/listc > output

motherscript

 ./001/script

lista

1 
2
3

listb

4
5
6

listc

7
8
9

output

1 
2
3
4
5
6
7
8
9
1
  • 3
    paths are not relative to the other scripts. If you invoke script as ./001/script and do not have anything in there that changes directory your path to, say, lista is 001/A/lista not just A/lista Aug 16, 2016 at 15:22

1 Answer 1

3

You use relative paths in script. So, you need to change your present working directory accordingly in motherscript before calling script.

# motherscript

cd 001
./script
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .