title: Batch file not executing psftp commands
body: <p>I am trying to upload a file from my local system to an FTP which is configured in Linux machine using T-SQL cmd. I have created a batch file with the commands to be executed which is working correctly in <code>cmd</code> where it is not working in T-SQL while calling the same batch file in SQL using xp_CMDShell. Please find below the commands I have used.</p>
  
  <p>Batch file cmd:</p>
  
  <pre><code>cd C:\Program Files\PuTTY
  psftp.exe
  open FTPip
  username
  password
  put D:\localpath\filename /home/destinationpath/filename
  quit 
  </code></pre>
  
  <p>T-SQL:</p>
  
  <pre><code>EXEC master..xp_CMDShell 'D:\batchfilepath\batchfile.bat'
  </code></pre>
  
  <p>T-SQL response:</p>
  
  <blockquote>
    <p>C:\Windows\system32>cd C:\Program Files\PuTTY  NULL C:\Program
    Files\PuTTY>psftp.exe psftp: no hostname specified; use "open
    host.name" to connect psftp> quit NULL C:\Program Files\PuTTY>open
    ftpip  'open' is not recognized as an internal or external command,
    operable program or batch file. NULL C:\Program Files\PuTTY>username
    'username' is not recognized as an internal or external command,
    operable program or batch file. NULL C:\Program Files\PuTTY>password
    'password' is not recognized as an internal or external command,
    operable program or batch file. NULL C:\Program Files\PuTTY>quit<br>
    'quit' is not recognized as an internal or external command, operable
    program or batch file. NULL</p>
  </blockquote>
  
  <p>Please let me know where I am missing.</p>