baptiste
baptiste

Reputation: 1169

Shell Script Error: No such file or directory

I am trying to run a shell script file from my USB drive which has to run an executable. I got this tree:

USBROOT/
    script.sh
    exe/
        myExe.exe
        Data/
            {Several Images}
        Results/
            {Results to be saved}

My .sh file looks like this(sorry, there is some french in the code :p):

#!/bin/sh
data="/exe/Data/"
exe="/exe/TopHat.exe"
rep_sortie="/exe/Results/"
fichier_sortie="GPU_Vivante_iMx6_linux.txt"
#
echo "Temps d'exécution du TopHat en secondes" >> $fichier_sortie
echo "Erosion G, Erosion L, Dilatation G, Dilatation L, Reconstruction V, Reconstruction AV, DT" >> $fichier_sortie
#
list_image=`ls ${data}U1*.jpg`
#
for f in $list_image 
do
image=${f##*/} 
#echo $image >> $fichier_sortie
$exe $f ${rep_sortie}${image} >> $fichier_sortie
done
#
list_image=`ls ${data}U2*.jpg`
#
for f in $list_image
do
image=${f##*/} 
#echo $image >> $fichier_sortie
$exe $f ${rep_sortie}${image} >> $fichier_sortie
done

But when I'm running it with the command line

sh script.sh

from the USBROOT directory I got a "No such file or directory" error. After several tries, I think my problem start when I declare my variables 'data' and 'rep_sortie'. Do you know what I am doing wrong ? I dont understand why it cannot see this directory.

I checked that I have the correct end of line LF.

Baptiste

Upvotes: 0

Views: 11594

Answers (1)

pRAShANT
pRAShANT

Reputation: 523

/exe/Data/ will search for the folder named under root location of linux filesystem ("/"), i.e. where all the folders like root, home, usr, tmp and mnt are placed. And script will not find any folder with name of "exe" it will report the error u got.Always if in a path / is prefixed, it translates to root of Linux filesystem.

There is difference between "/exe/Data"(Absolute path) and "./exe/Data"(Relative Path). I suppose later one is needed according to your requirement. AS:

./exe/Data will translate to ${PWD}/exe/Data which will surely not same as /exe/Data. where $PWD will prefix the present working directory.

Same modifications shall be made for /exe/TopHat.exe and other locations.

Upvotes: 1

Related Questions