简体   繁体   中英

File writing command in pexpect not behaving as I thought it would

There is a process that i can run from the command line which writes data to a file continuously until i tell it to stop, and can be accessed (read) while the process is running.

However, if I run the same command through pexpect, the file stays empty (although can be read) until I stop the pexpect instance. Only then will the file fill up with the data.

Is this just a feature of pexpect or am I doing something wrong here?

pexpect command:

child = pexpect.spawn('airodump-ng', ['-a', '-w', '/root/Desktop/TEST', '--output-format', 'csv', INTERFACE])

I have never used airodump-ng ; if it is a fire and forget exercise (no interaction), you should be using pexpect.run() for non-interactive tasks such as ls -la

results = pexpect.run('ls -la')

If you need interaction, just put your args in one string...

child = pexpect.spawn('airodump-ng -a -w /root/Desktop/TEST --output-format csv %s' % INTERFACE)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM