I am working on some code that will be a DD block device via SSH, and I want to do this using a subprocess so that I can track the status of DD during transmission (by killing the dd process with SIGUSR1 to get its current state and reading using selects )
The command I'm trying to implement will be something like this:
dd if=/dev/sda | ssh root@example.com 'dd of=/dev/sda'
The current method I tried was:
dd_process = subprocess.Popen(['dd','if=/dev/sda'],0,None,None,subprocess.PIPE, subprocess.PIPE) ssh_process = subprocess.Popen(['ssh','root@example.com','dd of=/dev/sda'],0,None,dd_process.stdout)
However, when I run this, the SSH process stops functioning after 10-40 seconds.
Am I completely dumb here or is there no way to lay between subprocesses?
Edit: Turns out my real code didn't have a hostname. This is the right way to do something.
python unix subprocess
Philip j
source share