Find the answer to your Linux question:
Results 1 to 2 of 2
I am trying to detect that a command was logged in my audit logs. To accomplish this, I am just tailing the log until either the expected entry appears or ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    1

    Simple Expect script question

    I am trying to detect that a command was logged in my audit logs. To accomplish this, I am just tailing the log until either the expected entry appears or expect times out:
    Code:
    send "tail -f /var/log/messages"
    expect "SYSCALL=foo*uid=bar"
    However, to do this I need to send the ^C (interrupt) command after I have found the entry I am looking for, otherwise tail will sit there until the timeout. How do I send interrupts?

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    I need to send the ^C (interrupt) command
    No ya don't.

    What happens when you run this script?
    Code:
    #!/bin/sh
    
    cat > dog <<EOD
    abcde
    asdf
    EOD
    
    cat > mouse <<EOD
    12345
    qwerty
    EOD
    
    expect <<EOD
    spawn tail -f dog
    set timeout 10
    expect asdf
    EOD
    
    expect <<EOD
    spawn tail -f mouse
    set timeout 10
    expect asdf
    EOD
    --
    Bill

    Old age and treachery will overcome youth and skill.

Posting Permissions

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