Fetching data from file

Hi All,

I'm facing issue while using script.

Chk_Etl_Status=`cat /dstage/questnet/qnetdv/input/Etl_Status.dat|cut -d"," -f1`
echo Chk_Etl_Status=$Chk_Etl_Status

above result is giving me sometime value as 1 and sometime error message as

Chk_Etl_Status=
dsjoblaunch.sh[153]: test: Specify a parameter with this command.

---------------------Input values---------------------
Input file name--

$ cat Etl_Status.dat
1,ETL STATUS

Input filepath--

$ pwd
/dstage/questnet/qnetdv/input

------------------------------------------------------

somebody pls look itno this. Am i writing some invalid script??

If you could provide the entire scirpt, we can check for error...the above line looks file to me. You can also do that same thing with the below code

Chk_Etl_Status=$(awk '{print $1}' FS=',' /dstage/questnet/qnetdv/input/Etl_Status.dat)
echo Chk_Etl_Status=${Chk_Etl_Status}
1 Like

I tried ur command with slight modification:

Chk_Etl_Status=`cat /dstage/questnet/qnetdv/input/Etl_Status.dat | cut -d"," -f1`
echo Chk_Etl_Status=$Chk_Etl_Status

Just added space after file name and before cut. Even i tried ur code and that also works..
Probably as SriniShoo said please share the entire script..

1 Like

Why not

IFS=, read Chk_Etl_Status REST < /dstage/questnet/qnetdv/input/Etl_Status.dat

?

Rudic-Are you sure the code you written is right??

Well, it worked for me, reading the 1 from /.../Etl_Status.dat into Chk_Etl_Status .
What be your result, or problem?