Run program from command line what prompts password and automatically provide password for it (cmd.exe, python)
Question: I have command line program what prompts password:

    
    
    > cwrsync root@NN.NN.NN.NN:/src /cygdrive/c/dst
    

Output (when i run it from cmd.exe command line):

    
    
    root@NN.NN.NN.NN's password:
    

When i input password manually, all OK. Output:

    
    
    skipping directory src
    

I want to provide password for it from command line or python script
automatically.

I tried:

One. From command line:

    
    
    > echo pass|cwrsync -r root@NN.NN.NN.NN:/src /cygdrive/c/dst
    

Not working. Output:

    
    
    root@NN.NN.NN.NN's password:
    

Two. From python script. test.py:

    
    
    import subprocess
    cmd = "cwrsync -r root@NN.NN.NN.NN:/src /cygdrive/c/dst"
    proc = subprocess.Popen(cmd1, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
    std1, std2 = proc.communicate("pass")
    print std1print std2
    

Not workin. Output:

    
    
    Permission denied, please try again.
    Permission denied, please try again.
    Permission denied (publickey,password).
    rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
    rsync error: unexplained error (code 255) at io.c(235) [Receiver=3.1.1]
    


Answer: It is common that security oriented programs ask for password on direct io
instead of reading stdin. And as :

    
    
    echo pass|cwrsync -r root@NN.NN.NN.NN:/src /cygdrive/c/dst
    

did ask password, I presume that csrsync directly reads from console.

In that case you cannot automate it without some work and low level
programming, because you will have to simulate keyboard actions. You should
instead search the documentations, because as it looks like it uses an
underlying `ssh`, it is likely to accept a public key pair. If it accept one
without passphrase, you should be able to automate it.

