Ignore:
Timestamp:
Sep 10, 2009, 2:55:51 AM (15 years ago)
Author:
Bruno Cornec
Message:

call_program_and_get_last_line_of_output is now allocating memory and returning that string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-files.c

    r2382 r2383  
    274274    char *kernel = NULL;;
    275275
    276     mr_asprintf(kernel, "%s", call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null"));
     276    kernel = call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null");
    277277   
    278278    // If we didn't get anything back, check whether mindi raised a fatal error
    279279    if (!kernel[0]) {
    280280        mr_asprintf(command, "%s", "grep 'Fatal error' /var/log/mindi.log");
    281         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     281        tmp = call_program_and_get_last_line_of_output(command);
    282282        if (strlen(tmp) > 1) {
    283283            popup_and_OK(tmp);
     
    331331    assert_string_is_neither_NULL_nor_zerolength(fname);
    332332    mr_asprintf(command, "which %s 2> /dev/null", fname);
    333     mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command));
     333    output = call_program_and_get_last_line_of_output(command);
    334334    mr_free(command);
    335335    if (output[0] == '\0') {
     
    340340        mr_asprintf(command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", output);
    341341        mr_free(output);
    342         mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command));
     342        output = call_program_and_get_last_line_of_output(command);
    343343        mr_free(command);
    344344    }
     
    346346        mr_asprintf(command, "dirname %s 2> /dev/null", output);
    347347        mr_free(output);
    348         mr_asprintf(output, "%s", call_program_and_get_last_line_of_output(command));
     348        output = call_program_and_get_last_line_of_output(command);
    349349        mr_free(command);
    350350    }
     
    428428    for (i = NOOF_ERR_LINES - 1; i >= 0 && !strstr(err_log_lines[i], "% Done") && !strstr(err_log_lines[i], "% done"); i--);
    429429    if (i < 0) {
    430         mr_asprintf(command, "tail -n3 %s | grep -Fi \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%');
    431         mr_asprintf(lastline, "%s", call_program_and_get_last_line_of_output(command));
     430        mr_asprintf(command, "tail -n3 %s | grep -Fi %% | tail -n1 | awk '{print $0;}'", filename);
     431        lastline = call_program_and_get_last_line_of_output(command);
    432432        mr_free(command);
    433433        if (!lastline[0]) {
     
    722722
    723723    log_it(command);
    724     mr_asprintf(sz_res, "%s", call_program_and_get_last_line_of_output(command));
     724    sz_res = call_program_and_get_last_line_of_output(command);
    725725    file_len_K = atol(sz_res);
    726726    log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
     
    779779                    mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
    780780                    log_it("command = %s", command);
    781                     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     781                    tmp = call_program_and_get_last_line_of_output(command);
    782782                    mr_free(command);
    783783
     
    10301030    }
    10311031
    1032     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("which mondorestore"));
     1032    tmp = call_program_and_get_last_line_of_output("which mondorestore");
    10331033    if (!tmp[0]) {
    10341034        mr_free(tmp);
     
    11011101    /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
    11021102    mr_asprintf(command, "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    1103     mr_asprintf(netfs_dev, "%s", call_program_and_get_last_line_of_output(command));
     1103    netfs_dev = call_program_and_get_last_line_of_output(command);
    11041104    mr_free(command);
    11051105
    11061106    mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
    1107     mr_asprintf(netfs_client_ipaddr, "%s", call_program_and_get_last_line_of_output(command));
     1107    netfs_client_ipaddr = call_program_and_get_last_line_of_output(command);
    11081108    mr_free(command);
    11091109
    11101110    mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
    1111     mr_asprintf(netfs_client_netmask, "%s", call_program_and_get_last_line_of_output(command));
     1111    netfs_client_netmask = call_program_and_get_last_line_of_output(command);
    11121112    mr_free(command);
    11131113
    11141114    mr_asprintf(command, "%s", "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
    1115     mr_asprintf(netfs_client_broadcast, "%s", call_program_and_get_last_line_of_output(command));
     1115    netfs_client_broadcast = call_program_and_get_last_line_of_output(command);
    11161116    mr_free(command);
    11171117
    11181118    mr_asprintf(command, "%s", "route -n | grep '^0.0.0.0' | awk '{print $2}'");
    1119     mr_asprintf(netfs_client_defgw, "%s", call_program_and_get_last_line_of_output(command));
     1119    netfs_client_defgw = call_program_and_get_last_line_of_output(command);
    11201120    mr_free(command);
    11211121
     
    11361136        log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", netfs_dev);
    11371137        mr_asprintf(command, "%s", "ifconfig %s | awk '{print $5}' | head -n1", netfs_dev);
    1138         mr_asprintf(mac_addr, "%s", call_program_and_get_last_line_of_output(command));
     1138        mac_addr = call_program_and_get_last_line_of_output(command);
    11391139        mr_free(command);
    11401140
     
    11431143        mr_free(netfs_dev);
    11441144
    1145         mr_asprintf(netfs_dev, "%s", call_program_and_get_last_line_of_output(command));
     1145        netfs_dev = call_program_and_get_last_line_of_output(command);
    11461146        mr_free(command);
    11471147
Note: See TracChangeset for help on using the changeset viewer.