how to read the relative path

suppose i ahve a shell script Nsdnet.sh inside a directory /dialp/Release/bin
another file nsdnet_file.csv is under the same directory. Now in the shell script i have call a java file, which reads the csvfile from the commandline.
Now when i run the file as
$ ./Nsdnet.sh ./nsdnet_file.csv
then the csv file is not read by the file.

Please help..
its urgent:confused:

So, you are writing a shell script,
passing the csv file name to it as parameter and
inside the script feeding the csv file to a java program...

Am I correct?

You might be doing wrong while calling the java program and feeding the csv file to it.

Show us what you are doing in shell script..

if [ "$1" = "" ];
then        ## No parameters were entered
    echo "Enter the fully qualified file name:"
    read mInputValue
else
    mInputValue=$1
    echo "The file name entered was "$mInputValue
fi


if [ ! -r $mInputValue ]
then
    echo "File either don't exist or is not readable" > ${DIALPBIN}/Nsdnet.log
    mailx -s "NSDNet processing failed" "xxxxx@rediffmail.com" < ${DIALPBIN}/Nsdnet.log
    exit 1
fi


count=`wc -l $mInputValue | cut -c1-9`
if [ $count -eq 0 ]
then
      
    echo "NSDNET Processing Failed because there are no records in the file" > ${DIALPBIN}/Nsdnet.log
    mailx -s "NSDNet processing failed" "xxxxxx@rediffmail.com" < ${DIALPBIN}/Nsdnet.log
    exit 1
fi


####################################################################
###Execute Nsdnet.class for processing the Input Files
####################################################################

echo "Processing started at `date`" > ${DIALPBIN}/Nsdnet.log
# ARG1 -----> Name of the Input File containing data to be inserted in database
cd ${BIPS_HOME}
if [[ -r $mInputValue ]]
then
    #echo "argument is $1"
    $JAVA_HOME/bin/java -Drelease_dir=$REL -classpath $CLASSPATH com.att.ams.interfaces.nsdnet.Nsdnet $mInputValue >> ${DIALPBIN}/Nsdnet.log
fi

echo "Processing ended at `date`" >> ${DIALPBIN}/Nsdnet.log

exit $?

it is working fine, if the full path is given
like $./Nsdnet.sh /dialp/release/bin/nsdnet_file.csv

but notm working when "./nsdnet_file.csv" name is given

It is because your java program is not at the same place where your csv file is...

Try...

#if you have passed the absolute path, it will take the .csv name
mInputValue=`basename $mInputValue`  

#And finally the absolute path.
`pwd`/$mInputValue 

Alternatively, You can use if-else and then pass the absolute path...

PS-- Always use code tags.

but nsdnet_file.csv can be any directory.
suppose it is one directory back, then the commandline argument will be
../nsdnet_file.csv

but in such case java file is not being called..

plz suggest some solution:confused:

Replace

$JAVA_HOME/bin/java -Drelease_dir=$REL -classpath $CLASSPATH com.att.ams.interfaces.nsdnet.Nsdnet $mInputValue ....

with

$JAVA_HOME/bin/java -Drelease_dir=$REL -classpath $CLASSPATH com.att.ams.interfaces.nsdnet.Nsdnet `pwd`/$mInputValue ...