Esempio n. 1
0
int main (void){
    struct sysinfo myinfo;
    unsigned long total_bytes;
    int num_vcpu,num_lv;

    sysinfo( &myinfo );
    total_bytes = myinfo.mem_unit * myinfo.totalram;

    puts("-------------------------------------");    
    printf("Memory: %lu MB\n", total_bytes/1024/1024);
    
    FILE *fp = popen("lscpu --extended=CPU | grep ^[0-9] | wc -l","r");
    fscanf(fp, "%d", &num_vcpu);
    printf("vCPUs: %d\n", num_vcpu);
    pclose(fp);

    puts("-------------------------------------");

    system ("lvs");

    FILE *fp2 = popen("lvs | wc -l","r");
    fscanf(fp2, "%d", &num_lv);
    pclose(fp2);
    if (num_lv >= 2){
        int ch;    
             
        printf("Delete any LVs? [y/n]:" );
        ch = getchar(); 
        while ( ch == 'y' || ch == 'Y'){
           puts("Inside while loop");

           printf("Delete additional LVs? [y/n]:" );
           clear_kb();
           ch = getchar();  
        }    
/*
char input[]="y";
        do{
            puts("Delete any LVs? [y/n]:" );
            fgets(input,10,stdin); 
            puts("INSIDE DO");           
        }        
        while(strcmp(input,"y")== 0);

*/      /*while*/
    }/*if*/




    return 0;
}
Esempio n. 2
0
int main( void )
{
  FILE *fp;
  float data[5];
  int count;
  char filename[20];

  puts("Enter 5 floating-point numberical values.");

  for (count = 0; count < 5; count++)
    scanf("%f", &data[count]);

  /* Get the filename and open the file. First clear stdin */
  /* of any extra characters. */

  clear_kb();

  puts("Enter a name for the file.");
  gets(filename);

  if ((fp = fopen(filename, "w")) == NULL)
    {
      fprintf(stderr, "Error opening file %s.", filename);
      exit(1);
    }

  /* Write the numerical data to the file and to stdout. */

  for (count = 0; count < 5; count++)
    {
      fprintf(fp, "\ndata[%d] = %f", count, data[count]);
      fprintf(stdout, "\ndata[%d] = %f", count, data[count]);
    }
  fclose(fp);
  printf("\n");
  return 0;
}