Hi all, I have been trying to execute the following unix shell script which is not working. I am running it by ksh.
echo $?;
if [ $? -ne 0 ]
then
failed $LINENO-2 $5 $6
fi
failed()
{
echo "$0 failed at line number $1";
echo "moving $2 to failed folder"
}
This is giving an error saying "Synatx error:then unexpected". Basically I have to check for the last executed korn shell script's highest/last statement's return code and if it is not equal to zero i have to call function failed with the given parameters. I tried putting semicolon before then that also dint work out.
Can you please help?
Edit: Based on the inputs i changed code. still the same problem exists.
ksh ../prescript/Pre_process $1 $2 $3
rc=$?;
if [[ $rc -ne 0 ]];then
echo "failed";
exit 1;
Edit2: Hi all, its working for the then part by using double squared brackets. I feel i used code of bash script for Ksh. but i am facing problem in function call of failed. Please let me know appropriate way of function call in korn shell for this example