in Education by
Have been needing to write some code that recognises (and captures) when there's incoming/outgoing smb transfers on my server. I think the best way is to use popen with 'iftop'. I was thinking I could just use popen to capture the data, but thing is iftop doesn't simply output the data - its an interactive environment that runs continuously until the user exits. So how can I parse values from these kind of programs into python? Alternatively - a better option that popen(iftop) ? Example: foo.Popen("iftop" + someArguments) //this is not stdout, so I can't pull string values (etc) from it :( //how does? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
import subprocess, time s = subprocess.Popen("iftop -s -t 1",shell=True,stdout=subprocess.PIPE) while not s.poll() == 0: time.sleep(1) print(s.stdout.read())

Related questions

0 votes
    Which module in the python standard library parses options received from the command line? a) getarg b) getopt c) main d) os...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    Which module in the python standard library parses options received from the command line? a) getarg b) getopt c) main d) os...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    Apparently, Microsoft has not yet made WebGL work in Internet Explorer by default. Plus, Opera have it only ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 15, 2022 in Education by JackTerrance
0 votes
    Why we use script mode for python programming while we have the interactive mode. Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
    How to use YAML files in high programming languages such as JAVA, Python, etc?...
asked Jul 28, 2021 in Technology by JackTerrance
0 votes
    I am trying to use ES2017 async/await syntax with Babel. In package.json, I have "babel": { " ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    I am trying to use ES2017 async/await syntax with Babel. In package.json, I have "babel": { " ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I am trying to use ES2017 async/await syntax with Babel. In package.json, I have "babel": { " ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    I need to create a hollow pyramid with a solid top layer like so: Height: 5 * *** * * * ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 5, 2022 in Education by JackTerrance
0 votes
    Top 10 Python IDEs And Code Editors In 2020...
asked Oct 27, 2020 in Technology by Editorial Staff
0 votes
    Is it possible in Windows to get a folder's size from the command line without using any 3rd party ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I'm using this script for building application from command line: #!/bin/bash TARGET="signtest" ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I've got two different apps that I am hosting (well the second one is about to go up) on Amazon EC2. ... path ; ec2-describe-instances Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I have file called q.r and it has chmod of 755, how can I run it using a command-line? sayHello...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I want to supply some command-line parameters from a R script I have. And it runs on windows. I just want it ... help me with it? Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
...