1

I have a problem with backquotes (it seems) in system() function in C. This is my request :

snprintf (check_cmd, sizeof (check_cmd), "[ $(echo -n '%.*s' | cksum | cut -d' ' -f1) -eq %" PRIu32 " ]", (cfi_sys_int)data_array[i].size, data_array[i].bytes, crc_32 );
system (check_cmd); 

I check the value of snprintf and system() return value but it doesn't return the good value

EOF
  • 6,273
  • 2
  • 26
  • 50
V. Pierre
  • 21
  • 3
  • 1
    It seems your example does not contain any backquotes. Is that the problem? – Jongware Apr 20 '16 at 13:06
  • 1
    "it doesn't return the good value" - which function? what value? What is the full string in `check_cmd` after `snprintf()`? – John Zwinck Apr 20 '16 at 13:13
  • For the return value, I should expect a 0 if it works, right ? but it's not the case. Then I put back quote and replace the "$(" and "). But it doesn't work yet. In fact, I've read that some shell doesn't support the "$(". Then I've checked the value of check_cmd, it's the good one. – V. Pierre Apr 20 '16 at 13:24
  • 1
    Read the documentation for `snprintf` again. That's not what it returns. – Art Apr 20 '16 at 14:14
  • This is not snprintf() value return. I know that snprintf return the number of bytes written and I check it, this is good. But when I put check_cmd in system(), system return a value != 0. – V. Pierre Apr 21 '16 at 08:35

0 Answers0