Find the answer to your Linux question:
Page 4 of 5 FirstFirst 1 2 3 4 5 LastLast
Results 31 to 40 of 42
The script runs, but at random times during the script, I get this error Code: ./testtuesday: line 33: printf: warning: `\': invalid time format specification ./testtuesday: line 33: printf: warning: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #31
    Just Joined!
    Join Date
    Jan 2011
    Posts
    87

    The script runs, but at random times during the script, I get this error
    Code:
    ./testtuesday: line 33: printf: warning: `\': invalid time format specification
    ./testtuesday: line 33: printf: warning: `?': invalid time format specification
    ./testtuesday: line 33: printf: warning: `?': invalid time format specification
    This is the script that I'm using.
    Code:
    #!/bin/bash
    basedir=/home
    dirs=$(ls $basedir)
    for user in "$basedir"/*; do
      echo -e "\nUsername: $user"
    
      for badword in steal quit kill bomb; do
    
        # temporarily change the bash input field separator
        OIFS=$IFS
        IFS='
    '
    
        # save any output containing badword to a variable
        lines=$(find $user -type f -exec grep -H -w $badword {} \;)
    
        for line in $lines; do
    
          # nothing to do if badword was not found
          [ -z "$line" ] && continue
    
          # get file and phrase from badword output
          file=$(echo $line|cut -f1 -d:)
          phrase=$(echo $line|sed -e "s|^$file:||")
          if [ -f whitelist.txt ]; then
    	cat whitelist.txt|grep -q "$phrase" && continue
          fi
    
          # ask if phrase should be ignored in the future
          read -p "Save '$phrase' to whitelist? [y|n] " save
    
          if [ "$save" == 'y' ]; then
            printf "$phrase\n" >> whitelist.txt
          fi
        done # done looping thru each line in the file
    
        # reset the input field separator
        IFS=$OIFS
    
      done # done looping thru all bad words
    
    done # done looping thru all user dirs
    It's also looping through the same 3 files while searching for "steal" and won't go beyond that.

  2. #32
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    printf problem on that line. change it from this:
    Code:
            printf "$phrase\n" >> whitelist.txt
    to this:

    Code:
            echo -e "$phrase" >> whitelist.txt
    and see if that helps. does that fix your "steal" prob, or is that something else?

  3. #33
    Just Joined!
    Join Date
    Jan 2011
    Posts
    87
    line 33: printf: -e: invalid option
    printf: usage: printf [-v var] format [arguments]

  4. #34
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    use "echo", not "printf", on line 33 of the script.

  5. #35
    Just Joined!
    Join Date
    Jan 2011
    Posts
    87
    the errors are gone, but it still just loops steal over and over.

  6. #36
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    can u post examples of a couple files containing the steal badword? also, what does the output of the script show?

  7. #37
    Just Joined!
    Join Date
    Jan 2011
    Posts
    87
    Code:
    quit commands as /home/user/vim/src/testdir/test49.vim: let quits = "" /ho" rather than "' to whitelist? [y|n]  " Use "
    This is the file that I use to determine if it's stuck in a loop, because the last line is " rather than "' and that's fairly easy to pick out. I guess it's for the word quit though.... my mistake.

  8. #38
    Just Joined!
    Join Date
    Jan 2011
    Posts
    87
    I still can't get the script to get out of that loop

  9. #39
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    Hey,
    Are u still having this loop problem? I can't replicate it. Can you post the contents of the file that you suspect is the problem (/home/user/vim/src/testdir/test49.vim i think?).

  10. #40
    Just Joined!
    Join Date
    Jan 2011
    Posts
    87
    That issue seems to have fixed itself, but now I get a trailing backslash problem
    Code:
    grep: Trailing backslash
    Save 'you for ****. Tell him that you worked with me on some cash jobs including lan\' to whitelist? [y|n] y
    grep: Trailing backslash
    Save '    =some really stupid **** happens to you. I don't know if I love you anymor\' to whitelist? [y|n] y
    grep: Trailing backslash
    Save 'you for ****. Tell him that you worked with me on some cash jobs including lan\' to whitelist? [y|n] y
    grep: Trailing backslash
    Save '    =some really stupid **** happens to you. I don't know if I love you anymor\' to whitelist? [y|n] y
    grep: Trailing backslash
    Save 'you for ****. Tell him that you worked with me on some cash jobs including lan\' to whitelist? [y|n] y
    I tried searching for a certain 4-letter word that this site censors with ****

Page 4 of 5 FirstFirst 1 2 3 4 5 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •