Changeset 273 in MondoRescue for branches/2.06/mondo/mondo/common


Ignore:
Timestamp:
Jan 3, 2006, 4:09:12 PM (18 years ago)
Author:
bcornec
Message:

Patches from Sébastien Aperghis-Tramoni <maddingue@…>

replace several occurences of "cat .. | grep .."
or with similar commands that accept filenames as arguments.
+ some sort | uniq replaced by sort -u

Location:
branches/2.06/mondo/mondo/common
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2.06/mondo/mondo/common/X-specific.cpp

    r30 r273  
    197197    kapp->quit();
    198198    printf ("---FATAL ERROR--- %s\n", error);
    199     system ("cat /var/log/mondo-archive.log | gzip -9 > /tmp/MA.log.gz 2> /dev/null");
     199    system ("gzip -9c /var/log/mondo-archive.log > /tmp/MA.log.gz 2> /dev/null");
    200200    printf ("If you require technical support, please contact the mailing list.\n");
    201201    printf ("See http://www.mondorescue.org for details.\n");
     
    252252  if (grep_for_me[0] != '\0')
    253253    {
    254       sprintf (command, "cat %s | grep \"%s\" | tail -n%d", filename,
    255            grep_for_me, NOOF_ERR_LINES);
     254      sprintf (command, "grep \"%s\" %s | tail -n%d",
     255           grep_for_me, filename, NOOF_ERR_LINES);
    256256    }
    257257  else
    258258    {
    259       sprintf (command, "cat %s | tail -n%d", filename, NOOF_ERR_LINES);
     259      sprintf (command, "tail -n%d %s", NOOF_ERR_LINES, filename);
    260260    }
    261261  fin = popen (command, "r");
  • branches/2.06/mondo/mondo/common/libmondo-devices.c

    r256 r273  
    14371437#else
    14381438    sprintf(command,
    1439             "cat /proc/filesystems | grep -v nodev | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
     1439            "grep -v nodev /proc/filesystems | tr -s '\t' ' ' | cut -d' ' -f2 | tr -s '\n' ' '");
    14401440#endif
    14411441
  • branches/2.06/mondo/mondo/common/libmondo-filelist.c

    r128 r273  
    656656  if (find_home_of_exe("setfacl"))
    657657    {
    658       sprintf(command, "cat %s | gzip -dc | setfacl --restore - 2>> %s", acl_fname, MONDO_LOGFILE);
     658      sprintf(command, "gzip -dc %s | setfacl --restore - 2>> %s", acl_fname, MONDO_LOGFILE);
    659659      log_msg(1, "command = %s", command);
    660660      retval = system(command);
     
    685685        log_msg(1,
    686686                "No masklist provided. I shall therefore set ALL attributes.");
    687         sprintf(command, "cat %s | gzip -dc | %s --restore - 2>> %s",
     687        sprintf(command, "gzip -dc %s | %s --restore - 2>> %s",
    688688                original_exat_fname, executable, MONDO_LOGFILE);
    689689        log_msg(1, "command = %s", command);
     
    712712    sort_file(masklist);
    713713    current_subset_file[0] = current_master_file[0] = '\0';
    714     sprintf(syscall_pin, "cat %s | gzip -dc", original_exat_fname);
     714    sprintf(syscall_pin, "gzip -dc %s", original_exat_fname);
    715715    sprintf(syscall_pout, "%s --restore - 2>> %s", executable,
    716716            MONDO_LOGFILE);
     
    833833  if (find_home_of_exe("setfattr"))
    834834    {
    835       sprintf(command, "cat %s | gzip -dc | setfattr --restore - 2>> %s", acl_fname, MONDO_LOGFILE);
     835      sprintf(command, "gzip -dc %s | setfattr --restore - 2>> %s", acl_fname, MONDO_LOGFILE);
    836836      log_msg(1, "command = %s", command);
    837837      retval = system(command);
  • branches/2.06/mondo/mondo/common/libmondo-files.c

    r234 r273  
    845845    sprintf(mountlist, "%s/mountlist.txt", tmpdir);
    846846    sprintf(command,
    847             "cat %s/mountlist.txt | grep \"%s \" | head -n1 | awk '{print $4;}'",
    848             tmpdir, dev);
     847            "grep \"%s \" %s/mountlist.txt | head -n1 | awk '{print $4}'",
     848            dev, tmpdir);
    849849    log_it(command);
    850850    strcpy(sz_res, call_program_and_get_last_line_of_output(command));
  • branches/2.06/mondo/mondo/common/libmondo-raid.c

    r128 r273  
    8080
    8181    command = malloc(MAX_STR_LEN * 2);
    82     strcpy(command, "cat /proc/mdstat | grep \"");
     82    strcpy(command, "grep \" /proc/mdstat");
    8383    if (raidno == -1) {
    8484        strcat(command, "linear");
  • branches/2.06/mondo/mondo/common/libmondo-tools.c

    r196 r273  
    335335           "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do \
    336336file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; \
    337 cat $file.old | awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } \
    338 else { print $0;};}' > $file ; fi ; done");
     337awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } \
     338else { print $0;};}'$file.old > $file ; fi ; done");
    339339    run_program_and_log_output(tmp, 5);
    340340    paranoid_free(tmp);
     
    10981098#ifndef __FreeBSD__
    10991099    if (run_program_and_log_output
    1100         ("cat /proc/devices | grep ramdisk", FALSE)) {
     1100        ("grep ramdisk /proc/devices", FALSE)) {
    11011101        if (!ask_me_yes_or_no
    11021102            ("Your kernel has no ramdisk support. That's mind-numbingly stupid but I'll allow it if you're planning to use a failsafe kernel. Are you?"))
     
    13901390    log_msg(4, "Done. Great. Seeting command to something");
    13911391    strcpy(command,
    1392            "cat /etc/fstab | grep -v \":\" | grep -vx \"#.*\" | grep -w \"/boot\" | tr -s ' ' '\t' | cut -f1 | head -n1");
     1392           "grep -v \":\" /etc/fstab | grep -vx \"#.*\" | grep -w \"/boot\" | tr -s ' ' '\t' | cut -f1 | head -n1");
    13931393    log_msg(4, "Cool. Command = '%s'", command);
    13941394    strcpy(tmp, call_program_and_get_last_line_of_output(command));
  • branches/2.06/mondo/mondo/common/libmondo-verify.c

    r128 r273  
    159159
    160160/*  sprintf (command,
    161        "cat %s | grep \"afio: \" | awk '{j=substr($0,8); i=index(j,\": \");printf \"/%%s\\n\",substr(j,1,i-2);}' | sort | uniq | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"/dev/.*\" > %s",
     161       "grep \"afio: \" %s | awk '{j=substr($0,8); i=index(j,\": \");printf \"/%%s\\n\",substr(j,1,i-2);}' | sort -u | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"/dev/.*\" > %s",
    162162       stderr_fname, afio_found_changes);
    163163*/
     
    165165    log_msg(1, "Now scanning log file for 'afio: ' stuff");
    166166    sprintf(command,
    167             "cat %s | grep \"afio: \" | sed 's/afio: //' | grep -vx \"/dev/.*\" >> %s",
     167            "grep \"afio: \" %s | sed 's/afio: //' | grep -vx \"/dev/.*\" >> %s",
    168168            stderr_fname, afio_found_changes);
    169169    log_msg(2, command);
     
    175175    log_msg(1, "Now scanning log file for 'star: ' stuff");
    176176    sprintf(command,
    177             "cat %s | grep \"star: \" | sed 's/star: //' | grep -vx \"/dev/.*\" >> %s",
     177            "grep \"star: \" %s | sed 's/star: //' | grep -vx \"/dev/.*\" >> %s",
    178178            stderr_fname, afio_found_changes);
    179179    log_msg(2, command);
     
    185185    afio_diffs = count_lines_in_file(afio_found_changes);
    186186    sprintf(command,
    187             "cat %s %s %s | sort | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s",
     187            "sort %s %s %s | uniq -c | awk '{ if ($1==\"2\") {print $2;};}' | grep -v \"incheckentry xwait()\" > %s",
    188188            ignorefiles_fname, afio_found_changes, afio_found_changes,
    189189            changedfiles_fname);
     
    401401                    g_current_media_number, bigfile_num, slice_num);
    402402            if (bkpinfo->compression_level > 0) {
    403                 sprintf(command, "cat %s | %s -dc 2>> %s",
     403                sprintf(command, "%s -dc %s 2>> %s",
     404                        sz_exe,
    404405                        slice_fname(bigfile_num, slice_num, mountpoint,
    405                                     bkpinfo->zip_suffix), sz_exe,
     406                                    bkpinfo->zip_suffix),
    406407                        MONDO_LOGFILE);
    407408            } else {
     
    543544        sprintf(command, "cat %s >> %s", outlog, MONDO_LOGFILE);
    544545    } else {
    545         sprintf(command, "cat %s | cut -d':' -f%d | sort | uniq", outlog,
    546                 (bkpinfo->use_star) ? 1 : 2);
     546        sprintf(command, "cut -d: -f%d %s | sort -u",
     547                (bkpinfo->use_star) ? 1 : 2, outlog);
    547548        pin = popen(command, "r");
    548549        if (pin) {
     
    580581    }
    581582    /*  chdir(old_pwd); */
    582     //  sprintf (tmp, "cat %s | uniq -u >> %s", "/tmp/mondo-verify.err", MONDO_LOGFILE);
     583    //  sprintf (tmp, "uniq -u %s >> %s", "/tmp/mondo-verify.err", MONDO_LOGFILE);
    583584    //  paranoid_system (tmp);
    584585    //  unlink ("/tmp/mondo-verify.err");
     
    11481149            (int) (random() % 32767));
    11491150    sprintf(tmp,
    1150             "cat %s | grep -x \"%s:.*\" | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"dev/.*\"  > %s",
    1151             MONDO_LOGFILE, (bkpinfo->use_star) ? "star" : "afio",
     1151            "grep -x \"%s:.*\" %s | cut -d'\"' -f2 | sort -u | awk '{print \"/\"$0;};' | tr -s '/' '/' | grep -v \"(total of\" | grep -v \"incheckentry.*xwait\" | grep -vx \"/afio:.*\" | grep -vx \"dev/.*\"  > %s",
     1152            (bkpinfo->use_star) ? "star" : "afio", MONDO_LOGFILE,
    11521153            changed_files_fname);
    11531154    log_msg(2, "Running command to derive list of changed files");
  • branches/2.06/mondo/mondo/common/newt-specific.c

    r213 r273  
    424424        printf("---FATALERROR--- %s\n", error_string);
    425425        system
    426             ("cat /var/log/mondo-archive.log | gzip -9 > /tmp/MA.log.gz 2> /dev/null");
     426            ("gzip -9c /var/log/mondo-archive.log > /tmp/MA.log.gz 2> /dev/null");
    427427        printf
    428428                ("If you require technical support, please contact the mailing list.\n");
Note: See TracChangeset for help on using the changeset viewer.