Hi Experts,
I am facing some problem while developing the script.My input config.csv file contains the three columns namely pathname,filename,filetype.Based on the file type i have to use ftp command that is if filetype=csv then do ftp.
The input file is
HTML Code:
cat config.csv
pathname,filename,filetype
/home/fir/dir,filename1,csv
/home/fir1/dir,filename2,csv
/home/fir4/dir,filename3,csv
/home/fir/dir6,filename4,dat
To achieve this i have developed the following script:
HTML Code:
#!/bin/ksh
head -5 config.csv | while read line
do
Type1=`echo $line | awk -F"," '{print $3}'`
Type=`echo $Type1 | tr [A-Z] [a-z]`
if [ $Type == 'csv' ]
then
DataFileName=`echo $line | awk -F"," '{print $2}'`
DataPath=`echo $line| awk -F"," '{print $1}'`
echo $DataPath
slash=`echo '\'`
filelocation=`echo $DataPath$slash$DataFileName`
echo do sftp -n
fi
done
Now the problem is that the value of DataPath variable is coming as
HTML Code:
echo $DataPath
homefirdir
Some how the slashes are getting removed.
How can we achieve the variable value as '/home/fir/dir ' and pass it to ftp command?
Thanks in Advance!