interesting enough, when I tried to clone object using bash shell
ssh -t -i ~/.ssh/security.pem [email protected] 'rm -rf myproject && git clon -b mybranch https://github.com/myproject.git'
everything works beautifully.
But when I tried to do it from python subprocess call, like
subprocess.check_call("ssh -t -i ~/.ssh/security.pem [email protected] 'rm -rf myproject && git clone -b mybranch https://github.com/myproject.git'", shell=True)
then I will get the following error:
fatal: destination path 'myproject' already exists and is not an empty directory.
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
check_call("ssh remote-host 'hostname && hostname'", shell=True)
or (better)check_call(["ssh", "remote-host", "hostname && hostname"])
to see that both commands are executed on the remote host. Python is not the issue, the issue is in your actual command (not the one that you've shown) -- check for stray single quotes. – jfs