All pastes #2091766 Raw Edit

Anonymous

public c v1 · immutable
#2091766 ·published 2011-10-20 13:01 UTC
rendered paste body
/***INCLUDE********************************************************/#include <stdio.h>#include <stdlib.h>#include <string.h>main (){FILE *ifstat;char data[2048];int i=1;char *bwin,*bwout;float ifstat_02,ifstat_05;ifstat = popen("ifstat -i eth0 -n 1 3|grep -vE \"eth0|KB/s\"","r");if(!ifstat){        fprintf(stderr, "Could not open pipe for output.\n");        return;}while ( fgets(data, sizeof data, ifstat ) != NULL ) {        bwin = strtok(data," ");        bwout = strtok(NULL," \n");        if ( i == 2 )        {                ifstat_02 = bwout;        }        printf("%d -> in: %s -> out: %s -> ifstat_02: %f\n",i,bwin,bwout,ifstat_02);        i++;}if (pclose(ifstat) != 0)        fprintf(stderr," Error: Failed to close command stream \n");return;}