supplying password to subprocess.call('rsync ...'), os.system('rsync ...')

Nicholas Bastin nick.bastin at gmail.com
Sun Oct 7 20:37:55 EDT 2007


On 05 Oct 2007 16:23:50 GMT, Stargaming <stargaming at gmail.com> wrote:
> On Fri, 05 Oct 2007 08:37:05 -0700, timw.google wrote:
> >> I can't ssh w/o supplying a password. That's the way the security is
> >> set up here.
> >>
> >> How do I use python to do this, or do I just have to write a zsh
> >> script?
> >>
> >> Thanks.
> >
> > I wrote a zsh script to do what I wanted, but I'd still like to know how
> > to do it in Python.
>
> `subprocess.Popen` has a keyword argument called `stdin` -- what takes
> the password, I guess. Assigning `subprocess.PIPE` to it and using
> `Popen.communicate` should do the trick.

SSH doesn't read passwords off of stdin.  If you want to supply a
password to SSH, then you need to control a pty directly.

--
Nick



More information about the Python-list mailing list