title: Sftp in python by invoking unix-shell commands
body: <p>How can we sftp a file from source host to a destinition server  in python by invoking unix shell commands in python script using os.system...Please help</p>
  
  <pre><code>I have tried the following code
  
  dstfilename="hi.txt"
  host="abc.com"
  user="sa"
  
  os.system("echo cd /tmp &gt;sample.txt)
  os.system("echo put %(dstfilename)s" %locals())  // line 2 
  os.system("echo bye &gt;&gt;sample.txt")
  os.system("sftp -B /var/tmp/sample.txt %(user)s@%(host)s)
  
  
  How to append this result of line to sample.txt?
  os.system("echo put %(dstfilename)s %locals()) &gt;&gt;sample.txt" // Seems this is syntatically not correct.
  
  cat&gt;sample.txt      //should look like this
  cd /tmp
  put /var/tmp/hi.txt
  bye
  
  Any help?
  
  Thanks you
  </code></pre>