I want to execute following command with system() function,
awk -F [][] '/dB/ { print $2 }' <(amixer sget Master) > sound_level
It gives me the desired output when I write in the terminal. But when I call this command with system function in C it gives me error.
My code is:
#include<stdio.h>
#include <stdlib.h>
int main()
{
system("awk -F [][] '/dB/ { print $2 }' <(amixer sget Master) > sound_level");
return 0;
}
It gives me the following error:
sh: 1: Syntax error: "(" unexpected
I have also tried:
awk -F [][] '/dB/ { print $2 }' < /(amixer sget Master /) > sound_level
but it does not work.
Any help is appreciated.
systemcallsystem()function is something different than a system call.main()function, but stripped of really everything that is not necessary to reproduce the problem. Nothing of what you have shown here is the cause of the error you get.