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 cmd
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.
Batch file cmd:
cd C:\Program Files\PuTTY
psftp.exe
open FTPip
username
password
put D:\localpath\filename /home/destinationpath/filename
quit
T-SQL:
EXEC master..xp_CMDShell 'D:\batchfilepath\batchfile.bat'
T-SQL response:
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
'quit' is not recognized as an internal or external command, operable program or batch file. NULL
Please let me know where I am missing.