awk "Invalid char ' in expession" error

I have an HP PPM (ITG) application that is running an awk command in cygwin bash shell as part of ITG process moving SAP transports on a Windows 2003 server. The awk command checks the first two characters of a file containing return code that was retrieved from the SAP server. It is throwing the error "invalid character ' in expression" . The following is the log:

sent command:
bash-2.05$ cat imp_619015_5.txt; echo KSC_EXIT_STATUS $?
received echo:
cat imp_619015_5.txt; echo KSC_EXIT_STATUS $?
00#!#Successful, Return Code: 00
KSC_EXIT_STATUS 0

sent command:
bash-2.05$ returncode=`cat imp_619015_5.txt | awk '{printf substr($1,1,2)}'`; echo KSC_EXIT_STATUS $?
received echo:
returncode=`cat imp_619015_5.txt | awk '{printf substr($1,1,2)}'`; echo KSC_EXIT_STATUS $?
awk: cmd. line:1: {printf substr($1,1,2)}
awk: cmd. line:1: ^ Invalid char ' in expression
KSC_EXIT_STATUS 2
Command: [returncode=`cat imp_619015_5.txt | awk '{printf substr($1,1,2)}'`] did not complete successfully.
Aborting command execution.
Closing telnet session.
Errors occurred during command execution.

When I run the awk command in the command line in the bash shell on the server and echo the returncode variable, it returns "00" as expected. Not sure why it is failing in ITG. Rebooting the server seems to solve the problem temporaraly but the problem comes back after a few days. Anyone have another way to run this command that I could try? Any ideas what could be causing the error? I do not have much experience in unix scripting.

The syntax of the printf statement isn't proper, it should looks like:

awk '{printf("%s", substr($1,1,2))}'

or use the print statement instead of printf:

awk '{print substr($1,1,2)}'

Regards

Thanks Franklin52 for your reply. I tried both but still get the error:

bash-2.05$ returncode=`cat imp_619015_5.txt | awk '{print substr($1,1,2)}'`; echo KSC_EXIT_STATUS $?
received echo:
returncode=`cat imp_619015_5.txt | awk '{print substr($1,1,2)}'`; echo KSC_EXIT_STATUS $?
awk: cmd. line:1: {print substr($1,1,2)}
awk: cmd. line:1: ^ Invalid char ' in expression
KSC_EXIT_STATUS 2
Command: [returncode=`cat imp_619015_5.txt | awk '{print substr($1,1,2)}'`] did not complete successfully.
Aborting command execution.
Closing telnet session.
Errors occurred during command execution.

I wonder if there is something corrupt with the bash or cygwin on the server?

Thanks,
accsam1

Try to replace this line:

returncode=`cat imp_619015_5.txt | awk '{print substr($1,1,2)}'`; echo KSC_EXIT_STATUS $?

with:

returncode=`cut -c1,2 imp_619015_5.txt`; echo KSC_EXIT_STATUS $?

Regards