In a bash script called through shell in some directory ($PWD), there is a line where I need to call an executable located at $PWD/bin so that it reads a input file located at $PWD/inputfiles and the resulting output files are stored in $PWD/output.
Can this be achieved?
PS: Now if I am at
cd /home/user
I do
./run config.inp output.dat
with config.inp being at /home/user
config.inp reads files data.txt and lines.txt which are in the same directory.
Now I want to read from /home/user/input and write the output files to /home/user/output
and I try
./run input/config.inp
it says
error, data.txt not found
As the problem is described, this will do it:
If the problem is really that
bin/executablecreates files in the current directory without allowing the user to specify the input and output files, then it will be a little more complicated. What you would probably want to do instead is:This will create a symbolic link to
inputfiles/inputfrom within theoutputdirectory, and then delete it later. If you want to eliminate the chance of collisions with files in theoutputdirectory, then you need to create a temporary directory with something likeTMPDIR = $(mktemp -d), do everything there, and then copy it back to$OLDPWD/output.