Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: autoflush output when '-o -' is used #812

Open
HuntClauss opened this issue Dec 29, 2023 · 0 comments
Open

Feature: autoflush output when '-o -' is used #812

HuntClauss opened this issue Dec 29, 2023 · 0 comments

Comments

@HuntClauss
Copy link
Contributor

Description

When -o - is used as an output file, in some cases internal buffer stores output and flush it only after end of execution.

Example

#!/usr/bin/env python

from subprocess import Popen, PIPE, DEVNULL

proc = Popen(["nikto", "-h", "https://example.com", "-Format", "csv", "-o", "-"], stdout=PIPE, stdin=DEVNULL, stderr=DEVNULL)

while True:
    line = proc.stdout.readline().decode("utf8")
    if proc.poll() is not None:
        break

    print(line, end="")

This could be changed by setting autoflush(1) when -o - was used or after some flag was provided eg. -Flush or -Autoflush.

Links/Info

One of the potential solutions for this could be this:

my $handle;
if (defined $plugin->{report_head}) {
$handle = &{ $plugin->{report_head} }($file);
}

 my $handle; 
 if (defined $plugin->{report_head}) { 
     $handle = &{ $plugin->{report_head} }($file);
     if ($file eq "-") { $handle->autoflush(1); }
 } 

After discussing what solution would be best I can create PR with it.

@HuntClauss HuntClauss changed the title Feature: autoflush output when '-o -' was used Feature: autoflush output when '-o -' is used Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant