pipe - Python popen wont work with block devices -


I have a small forensic app that looks like this

  import time, OS Print "file \ n" pipe = os.popen ("xxd" + filename), "sys def getter (): filename = sys.argv [1] print" file entered: "+ filename OSSystem ('file' , "R") print pipe.read ()  

I input through a command line through a file and prints the file type and then from the terminal A pipe maker Go back to the Python app under the name "Pipe". Then I read a pipe named "Pipe"

This works very well on small text files, but this will not work on block device even when I Run this user as a super user. In the end it will fix the file based on XXD output.

Any tips, thanks

If you just by xxd / What happens if dev / diskwhich runs ? Does this work, and how much information does it take? Thinking that as a superuser, you have read the permission, in the last line of your code, an attempt to read everything in the sip, where failure can be expected (because the amount of information can be very large) ; Call.

Edit : Whether you get your account in a good modern way with a pipe (with subprocess ) or dislikes just yet In the old way (with popen ), this problem does not matter. In either case, you can get a line at a time by simply looping on the pipe object, for example:

  child = subprocess.Popen (whatever, stdout = subprocess.PIPE ) Child.stdout in line: print "one more row:", line  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -