Error executing UNIX shell script from after job routine
Moderators: chulett, rschirm, roy
Error executing UNIX shell script from after job routine
Hi,
Am having a script to execute after Job finishes, and i have specified it in the After Job Routine in (ExecSh) of the DS Job.
The script name is rejectfile.sh
And the script file contains
if
[[ `awk 'END{print NR}' /RejectFiles/Extractrejectfile.csv` -gt 1 ]]
then
uuencode /RejectFiles/Extractrejectfile.csv Extractrejectfile.csv|mailx -s Extract Errorfile xyz@hotmail.com
else
echo "File is empty"
fi
If i run this script in the UNIX, its executing correctly. But if i run using the DS job after job routine am getting the following error.
/RejectFiles/rejectfile.sh: [[: not found
File is empty
Can you pls help me out, how to achieve this.
Rgds,
Senthil MP
**Note: Subject changed to be more descriptive - Content Editor **
Am having a script to execute after Job finishes, and i have specified it in the After Job Routine in (ExecSh) of the DS Job.
The script name is rejectfile.sh
And the script file contains
if
[[ `awk 'END{print NR}' /RejectFiles/Extractrejectfile.csv` -gt 1 ]]
then
uuencode /RejectFiles/Extractrejectfile.csv Extractrejectfile.csv|mailx -s Extract Errorfile xyz@hotmail.com
else
echo "File is empty"
fi
If i run this script in the UNIX, its executing correctly. But if i run using the DS job after job routine am getting the following error.
/RejectFiles/rejectfile.sh: [[: not found
File is empty
Can you pls help me out, how to achieve this.
Rgds,
Senthil MP
**Note: Subject changed to be more descriptive - Content Editor **
If you are just checking the file is empty or not, why dont you just try to use -s flag..
I guess that could also help the remove the error which you are getting.. I suspect it is due to awk which you are using in the if loop.
I guess that could also help the remove the error which you are getting.. I suspect it is due to awk which you are using in the if loop.
-----------------------------------
Regards
MK
What would you attempt to do if you knew you could not fail?
-----------------------------------
Regards
MK
What would you attempt to do if you knew you could not fail?
-----------------------------------
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
if
[[ `awk 'END{print NR}' /RejectFiles/Extractrejectfile.csv` -gt 1 ]]
then
uuencode /RejectFiles/Extractrejectfile.csv Extractrejectfile.csv|mailx -s Extract Errorfile xyz@hotmail.com
else
echo "File is empty"
fi
Else contains the 'file is empty'.that means it should be containing any records ! :D
Senthil,
Are you looking for empty file ?
In if loop are you checking for the records more than one or zero ?
[[ `awk 'END{print NR}' /RejectFiles/Extractrejectfile.csv` -gt 1 ]]
then
uuencode /RejectFiles/Extractrejectfile.csv Extractrejectfile.csv|mailx -s Extract Errorfile xyz@hotmail.com
else
echo "File is empty"
fi
Else contains the 'file is empty'.that means it should be containing any records ! :D
Senthil,
Are you looking for empty file ?
In if loop are you checking for the records more than one or zero ?
-----------------------------------
Regards
MK
What would you attempt to do if you knew you could not fail?
-----------------------------------
Regards
MK
What would you attempt to do if you knew you could not fail?
-----------------------------------
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
I assume so.
Senthil, what is your user's default shell? I'll wager it is different from DataStage and your syntax is shell specific. That ".sh" file extension is meaningless, you need to set it in the script itself. For example:
As the first line to force it to use the shell matching your file's extension. But double-check what your user's default is, the one that works, and set that one in the script.
Senthil, what is your user's default shell? I'll wager it is different from DataStage and your syntax is shell specific. That ".sh" file extension is meaningless, you need to set it in the script itself. For example:
Code: Select all
#! /usr/bin/sh
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 3337
- Joined: Mon Jan 17, 2005 4:49 am
- Location: United Kingdom
Re: Trouble in calling Unix script
senthilmp wrote:If i run this script in the UNIX, its executing correctly.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers