Skip to main content
Tweeted twitter.com/#!/StackUnix/status/341300894207447040
retagged; improved title (more general)
Link
Hauke Laging
  • 94.6k
  • 21
  • 132
  • 185

tail -f AND output while reading keyboard input

formatting
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

I'm trying to write a script that will sshssh into a box, start a processes that needs to be monitored (by a human) for success or failure then move onto the next box and repeat.

I've been trying to use tail or tail -f on the log that the process writes to, but I've yet to find a way to get the script to read keyboard input while the tail -ftail -f is running.

Ideally I'd like to tail -f the log until I see the process was successful, press a key and have the script move on, OR press another key if the startup errors out and exit the script.

Is this possible?

So far I've only come up with:

    #!/bin/bash
    kb=""
    until [ "$kb" == "n" ]; do
    tail /var/log/java-app.log
    read -t 1 kb
    done

It mostly works, but it's klunky. I'm starting up java apps and there are pauses so occasionally the same 10 lines are repeated and I have to hit 'enter'enter to have the 'n'n acknowledged. I'd really like to use tail -f and still read (ideally 2) different vars from the keyboard. Is this possible?

{edit} 
I'm actually thinking that

tail -f /var/log/java-app.log | tee > ( grep -q "YADA YADA" )

Is my best bet. I can just ctrl+CCtrl+C if I find errors.

I'm trying to write a script that will ssh into a box, start a processes that needs to be monitored (by a human) for success or failure then move onto the next box and repeat.

I've been trying to use tail or tail -f on the log that the process writes to, but I've yet to find a way to get the script to read keyboard input while the tail -f is running.

Ideally I'd like to tail -f the log until I see the process was successful, press a key and have the script move on, OR press another key if the startup errors out and exit the script.

Is this possible?

So far I've only come up with:

    #!/bin/bash
    kb=""
    until [ "$kb" == "n" ]; do
    tail /var/log/java-app.log
    read -t 1 kb
    done

It mostly works, but it's klunky. I'm starting up java apps and there are pauses so occasionally the same 10 lines are repeated and I have to hit 'enter' to have the 'n' acknowledged. I'd really like to use tail -f and still read (ideally 2) different vars from the keyboard. Is this possible?

{edit} I'm actually thinking that

tail -f /var/log/java-app.log | tee > ( grep -q "YADA YADA" )

Is my best bet. I can just ctrl+C if I find errors.

I'm trying to write a script that will ssh into a box, start a processes that needs to be monitored (by a human) for success or failure then move onto the next box and repeat.

I've been trying to use tail or tail -f on the log that the process writes to, but I've yet to find a way to get the script to read keyboard input while the tail -f is running.

Ideally I'd like to tail -f the log until I see the process was successful, press a key and have the script move on, OR press another key if the startup errors out and exit the script.

Is this possible?

So far I've only come up with:

    #!/bin/bash
    kb=""
    until [ "$kb" == "n" ]; do
    tail /var/log/java-app.log
    read -t 1 kb
    done

It mostly works, but it's klunky. I'm starting up java apps and there are pauses so occasionally the same 10 lines are repeated and I have to hit enter to have the n acknowledged. I'd really like to use tail -f and still read (ideally 2) different vars from the keyboard. Is this possible?

{edit} 
I'm actually thinking that

tail -f /var/log/java-app.log | tee > ( grep -q "YADA YADA" )

Is my best bet. I can just Ctrl+C if I find errors.

I'm trying to write a script that will ssh into a box, start a processes that needs to be monitored (by a human) for success or failure then move onto the next box and repeat.

I've been trying to use tail or tail -ftail -f on the log that the process writes to, but I've yet to find a way to get the script to read keyboard input while the tail -f is running.

Ideally I'd like to tail -ftail -f the log until I see the process was successful, press a key and have the script move on, OR press another key if the startup errors out and exit the script.

Is this possible?

So far I've only come up with:

    #!/bin/bash
    kb=""
    until [ "$kb" == "n" ]; do
    tail /var/log/java-app.log
    read -t 1 kb
    done

It mostly works, but it's klunky. I'm starting up java apps and there are pauses so occasionally the same 10 lines are repeated and I have to hit 'enter' to have the 'n' acknowledged. I'd really like to use tail -ftail -f and still read (ideally 2) different vars from the keyboard. Is this possible?

{edit} I'm actually thinking that tail -f /var/log/java-app.log | tee > ( grep -q "YADA YADA" ) Is

tail -f /var/log/java-app.log | tee > ( grep -q "YADA YADA" )

Is my best bet. I can just ctrl+C if I find errors.

I'm trying to write a script that will ssh into a box, start a processes that needs to be monitored (by a human) for success or failure then move onto the next box and repeat.

I've been trying to use tail or tail -f on the log that the process writes to, but I've yet to find a way to get the script to read keyboard input while the tail -f is running.

Ideally I'd like to tail -f the log until I see the process was successful, press a key and have the script move on, OR press another key if the startup errors out and exit the script.

Is this possible?

So far I've only come up with:

    #!/bin/bash
    kb=""
    until [ "$kb" == "n" ]; do
    tail /var/log/java-app.log
    read -t 1 kb
    done

It mostly works, but it's klunky. I'm starting up java apps and there are pauses so occasionally the same 10 lines are repeated and I have to hit 'enter' to have the 'n' acknowledged. I'd really like to use tail -f and still read (ideally 2) different vars from the keyboard. Is this possible?

{edit} I'm actually thinking that tail -f /var/log/java-app.log | tee > ( grep -q "YADA YADA" ) Is my best bet. I can just ctrl+C if I find errors.

I'm trying to write a script that will ssh into a box, start a processes that needs to be monitored (by a human) for success or failure then move onto the next box and repeat.

I've been trying to use tail or tail -f on the log that the process writes to, but I've yet to find a way to get the script to read keyboard input while the tail -f is running.

Ideally I'd like to tail -f the log until I see the process was successful, press a key and have the script move on, OR press another key if the startup errors out and exit the script.

Is this possible?

So far I've only come up with:

    #!/bin/bash
    kb=""
    until [ "$kb" == "n" ]; do
    tail /var/log/java-app.log
    read -t 1 kb
    done

It mostly works, but it's klunky. I'm starting up java apps and there are pauses so occasionally the same 10 lines are repeated and I have to hit 'enter' to have the 'n' acknowledged. I'd really like to use tail -f and still read (ideally 2) different vars from the keyboard. Is this possible?

{edit} I'm actually thinking that

tail -f /var/log/java-app.log | tee > ( grep -q "YADA YADA" )

Is my best bet. I can just ctrl+C if I find errors.

added 156 characters in body
Source Link
kadamwolfe
  • 93
  • 1
  • 1
  • 6
Loading
Source Link
kadamwolfe
  • 93
  • 1
  • 1
  • 6
Loading