I am trying to write a python script which uses scp
to log into a HPC cluster (where I have an account) and transfer files from the cluster to my local system. I am able to os.system()
to type the scp
command. But, after that, I am a bit confused about what I must do when I am asked for the password (assume my password is password
). I have tried os.system('password')
and print 'password'
, but they don't work.
This is the python script that I have written:
import os
import sys
password = 'password'
clusterpath = 'myname@cluster.hpc1.cs.univ.edu:/Projects/re* '
localpath = 'Projects/.'
os.system('scp ' + clusterpath + localpath)
When I execute this script, I am asked for the password of my cluster. How can I enter the password of the cluster account through this python script?