Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4538638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:50:18+00:00 2026-05-21T14:50:18+00:00

Hi I want to read tail -f with a groovy process for a while,

  • 0

Hi I want to read tail -f with a groovy process for a while, then take what I got from it and destroy the process. I’m doing it in a “watchman-class”-setting (that is I execute the process at the start of the test, and want to get out the data after the test has been completed).

Problem is that I’m not getting anything out of the process (process.in.text), even though lots has been written to the file I’m reading from.

I’ve tried to see if anyone’s attempted this before, but couldn’t find any good resource on the matter.

Here’s some code from the start and end of the test watchman:


  @Override
    void starting(FrameworkMethod method) {
        if (testCase.logs) {
            println "===> Fetching logs enabled."
            def commands = []
            pathMap.each {key, value ->
                String host = environmentEnvName.toLowerCase() + key.toString()
                value.each {it ->
                    commands.add "ssh ${user}@${host} tail -f '${it}'"
                }
            }
            println "===> Executing processes"
            commands.each {command ->
                procs.add command.execute()
            }
            println "===> ${procs.size()} processes exceuted"
        }
    }


    @Override
    void finished(FrameworkMethod method) {
        if (procs) {
            println "===> Ready to write files and destroy processes."

            def reportDate = new Date()
            procs?.eachWithIndex {proc, index ->
                def target = String.format("%s/target/${index}-%s.txt", userdir, reportDate.format("HHmm-ddMMyyyy"))
                if(proc.in.text){
                    new File(target).write(proc.in.text)
                }
                proc.destroy()
            }

            println "===> Log exerpts written. Processes destroyed."

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T14:50:19+00:00Added an answer on May 21, 2026 at 2:50 pm

    Process.getText() and InputSteam.getText() read the input fully before returning and doesn’t necessarily return anything if you destroy the process. You can get around this by reading in the output line by line, or just passing the stream to the output file directly:

    proc.in.newReader().eachLine { line ->
        // do something with line
    }
    // or
    new File(target) << proc.in
    

    Incidentally, tail -f is usually used interactively, rather than by a program. If you want to set the delta of a log file before and after a test, it would be much simpler to just take the file size before, then reopen the file and seek to the old end and start reading from there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to read data about MMORPG characters from a .txt file and then
I want to read cartesian coordinates of a large set of points from of
I want to read lines from a file into a Set or List. Is
I want to read UTF-8 strings from a server that I have control of,
I want to read from stdin five numbers entered as follows: 3, 4, 5,
I want to read data from a website with cURL but from a certain
I want to read the values from a select dropdown in jquery and populate
i want read data from the binary file named xyz.bin and want to parse
I want to read some code from a file and give this to a
I want to read string from standart input and output it in on console.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.