using cp command inside nawk

Hello

I have facing issue while using cp command inside nawk block.

#!/bin/ksh
my_name=$1
nawk  -v my_name1=$my_name 'BEGIN {
n = split(my_name1,names,":");
for (i=1;i<=n;i++)
{
print names;
cpcmd = "cp " /tmp/test.txt" " ./sample
system(cpcmd)
}
exit
}'
exit 0

i'am getting below error

nawk: syntax error at source line 6
 context is
        cpcmd = "cp " >>>  /tmp/test. <<< txt " " ./sample
nawk: illegal statement at source line 6

Can anyone tell the correct syntax for copy the file inside awk block or what is the problem here in this code.

Thanks in advance

I don't see if/how you're 'names[i]' for your 'cp', but......

cpcmd = "cp  /tmp/test.txt ./sample"
system(cpcmd)
close(cpcmd)