execl() 関数を使用してプロセスを呼び出す ac プログラムを作成しています。プロセスの出力と C プログラムの出力を取得します。execl() を使用して呼び出されたプロセスの出力をファイルに保存する必要があります。プログラミングの基礎と、ファイルの入出力も知っています。
これが私のプログラムです:
#include<stdio.h>
#include<unistd.h>
main()
{
printf("\nDisplaying output of ifconfig\n");
execl("/sbin/ifconfig","ifconfig",NULL);
}
出力:
Displaying output of ifconfig
eth1 Link encap:Ethernet HWaddr 02:00:00:a1:88:21
...........
lo Link encap:Local Loopback
........
ifconfig の出力をファイルに保存する必要があります。どうすればできますか?