awk value return

I have a script in awk and i have a unix shell script too ,and i want to call from the unix shell the awk script but that is returning a value according to what have been checked and found like boolean value in the awk script.
How do i do it?

It's not clear what you're trying to achieve, can you clarify your question with an example?

Regards

the usual way to execute an awk script is

awk -f awkscript filename

cheers,
Devaraj Takhellambam

#!/bin/sh
awk -f input_check.awk strings.txt \\here i want the input_check.awk script to return a value that is boolean to the value will be used after this line with a if condition
awk -f messview.awk messages
awk -f report_maker.awk warn.txt
i=1;
new="yes"
for file in `ls`
do
file_check="part"$i;
if [ "$file" = "$file_check" ]
then
if [ "$new" = "yes" ]
then
cat $file_check > "reporta.txt"
new="no"
else
cat $file_check >> "reporta.txt"
fi
rm $file_check
(( i = i+1 ))
fi
done

retval=`awk -f input_check.awk strings.txt`

Make sure you return either a 0 or 1 in your awkscript. Then you can test in your unix script for 0 or 1.

cheers,
Devaraj Takhellambam

But how can i return the value like this with awk?

 print "0"

or

print "1"

To be more preciser, the above statements echo the return code on the screen. The way to get the return code with the above statements in your script is:

retval=`awk -f input_check.awk strings.txt`

To return an exit code you can use the exit statement of awk:

exit(ReturnCode)

The return code can then be retrieved with:

retval=`echo $?`

GNU nano 2.0.6 File: union.sh

#!/bin/sh
error=`awk -f input_check.awk strings.txt`
if [ "$error" = "ok" ]
then
awk -f messview.awk messages
awk -f report_maker.awk warn.txt
i=1;
new="yes"
for file in `ls`
do
file_check="part"$i;
if [ "$file" = "$file_check" ]
then
if [ "$new" = "yes" ]
then
cat $file_check > "reporta.txt" GNU nano 2.0.6 File: union.sh

#!/bin/sh
error=`awk -f input_check.awk strings.txt`
if [ "$error" = "ok" ]
then
awk -f messview.awk messages
awk -f report_maker.awk warn.txt
i=1;
new="yes"
for file in `ls`
do
file_check="part"$i;
if [ "$file" = "$file_check" ]
then
if [ "$new" = "yes" ]
then
cat $file_check > "reporta.txt"
new="no"
else
cat $file_check >> "reporta.txt"
fi
rm $file_check
(( i = i+1 ))
fi
done
fi

new="no"
else
cat $file_check >> "reporta.txt"
fi
rm $file_check
(( i = i+1 ))
fi
done
fi

I have this script now and the problem that if i want that the variable will get the value i need to do the command echo $error and then it prints the value of error too which i do not want to happen.
How can i avoid printing its value?

Don't confuse with the last replay ,i posted the script twice ,start reading from the second "#!/bin/sh"

In the case of the awk exit mode it allways returns 0 ,how can i make the script return a value like i want?

As Franklin52 mentioned,

exit somenumber  (in your awk script)
ret=`echo $?`

( in the shell script)

Can you paste your awk script also?

cheers,
Devaraj Takhellambam

BEGIN{ error="false";line=1;
}
{
check_count=split($0,count," ");
if (check_count<=3)
{
printf("Not enough sub strings in line %d should have method ,figures of row and count syntax and at least on$
error="true";
}
if ($1!="row"&&$1!="all")
{
printf("Bad name of words appearance metrhod on line %d, should be "all" or "row"\n",line);
error="true";
}
digits[1] = 0;
digits[2] = 0;
len[1] = split( $2, arr1 ,"" )
len[2] = split( $3, arr2 ,"" )
for ( i = 1; i <= len[1]; i++ )
if (( arr1 [i]+ 0 ) == arr1 [i])
digits[1]++
for ( i = 1; i <= len[2]; i++ )
if (( arr2 [i]+ 0 ) == arr2 [i])
digits[2]++
for (i=1;i<=2;i++)
{
if (i==1)
str="row";
else
str="all";
if ( len [i]!= digits[i]||digits[i]<0 )
{
printf("Invaild value for the %s field on line %d should be numeric and equal or great from 0\n",str,line);
error="true";
}
}
}
END {exit(error);
}

Don't use a literal "true" or "false" as a return value but a 0 for true and another number for false.