aix :grep to get lines before and after string

am using AIX and I have a string "There is no process to read data written to a pipe". I want to get the output 2 lines before and 4 lines after this string. The string is present like more than 100 times in the log and I want to output, the last result in the log with this string

I tried using :

nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=2   a=4 s="There is no process to read data written to a pipe" File.log

The output from this command is that I am getting all the 100 plus results where the above string is present

The -A number -B number command is not working in AIX

You need to retain the output until the end and reset it at every match.
Here is a sample code, though not very elegant:

nawk 'c-->0{res=sprintf("%s%s\n",res,$0)};$0~s{res="";if(b)for(c=b+1;c>1;c--)res=sprintf("%s%s\n",res,r[(NR-c+1)%b]);res=sprintf("%s%s\n",res,$0);c=a}b{r[NR%b]=$0}END{printf("%s",res)}' b=2   a=4 s="There is no process to read data written to a pipe" File.log