0

I am trying to download/copy/move file using SFTP in SSIS by using psftp.exe. My question in SSIS Execute Process Task how to write the arguments. In folder I have psftp.exe, one batch file (b.bat).

Username : user11
Password : pass***
host : Server name :  mftobinternal.com

Now I am passing them in argument :

user11@mftobinternal.com -pw pass*** -be batch -b b.bat

Is this a right way? Because I am getting error.

Error : [Execute Process Task] Error: In Executing "C\FTP\psftp.exe" "user11@mftobinternal.com -pw pass*** -be batch -b Batch.bat" at "C\FTP", The process exit code was "1" while the expected was "0".

Thank you!

  • PuTTY and psftp are two different applications. I assume you use psftp, not PuTTY, so please remove all references to PuTTY from your question --- *"I am getting error"* - what error??? – Martin Prikryl Jan 23 '19 at 15:43
  • @Martin , Done the editing, Added the error as well in question. My original question, Am I passing the arguments in a correct way ? – usama.nomani Jan 23 '19 at 15:49
  • There's still PuTTY in question title and in tags. – Martin Prikryl Jan 23 '19 at 15:50
  • I'm quite sure you are missing `-hostkey` switch. See [PuTTY PSFTP command line works as Admin, fails as User](https://stackoverflow.com/q/42141404/850848). – Martin Prikryl Jan 23 '19 at 15:52
  • I tried adding host key but no luck , however when I am running this in cmd, it;s transferring the file. I have a strong sense if I am passing values in correct manner in Argument . Please look into the argument to double check if I am making some mistake there . – usama.nomani Jan 24 '19 at 09:10
  • I do not see anything wrong in your arguments. -- Did you try putting your psftp command to a batch file and run the batch file from SSIS? This way, you can redirect psftp output to a file in the batch file and inspect the output file for the error message. --- `psftp user11@mftobinternal.com -pw pass*** -be batch -b b.bat -hostkey aa:bb:cc:... > C:\some\writable\path\psftp.log` – Martin Prikryl Jan 24 '19 at 09:16
  • Error: 0xC0029151 at Execute Process Task, Execute Process Task: In Executing "C:\FTP\psftp.exe" "user11@mftobinternal.com -pw pass**** -be batch -b b.bat -hostkey=9b:64:24:b2:0c:56:ab:94:1d:15:80:90:3a:b1:3a:01" at "C:\FTP", The process exit code was "1" while the expected was "0". Task failed: Execute Process Task Warning: 0x80019002 at SFTP_SSIS_LD: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED. The Execution method succeeded, but the number of errors raised (1) reached the maximum allowed (1); resulting in failure. The program '[62224] DtsDebugHost.exe: DTS' has exited with code0 – usama.nomani Jan 24 '19 at 11:56
  • I've asked you to try to execute a batch file from SSIS. You are still executing `psftp`. Put the command from my previous comment to a batch file (e.g. `test.bat`) and in SSIS specify `C:\path\to\test.bat` instead of `psftp`, with no arguments. --- I'm actually not sure, if SSIS can execute batch files directly. If not, use `cmd.exe` as a program and `/C C:\path\to\test.bat` as an argument. – Martin Prikryl Jan 24 '19 at 12:53
  • I tried executing .bat directly, same error, it does create sftp.log file, but log file is empty both times when I run .bat directly and through cmd as well. Here is the command that I am pasting in ssis.bat file . ` psftp user11@mftobinternal.com -pw pass**** -be batch -b ssis.bat -hostkey=9b:64:24:b2:0c:56:ab:94:1d:15:80:90:3a:b1:3a:01" > C:\FTP\psftp.log get file.txt ` . – usama.nomani Jan 25 '19 at 08:17
  • You have an unmatched double-quote in your command, remove it. + What is `get file.txt`? That should not be there. + Redirect also error output with `2>&1` --- `psftp user11@mftobinternal.com -pw pass**** -be batch -b ssis.bat -hostkey=9b:64:24:b2:0c:56:ab:94:1d:15:80:90:3a:b1:3a:01 > C:\FTP\psftp.log 2>&1` – Martin Prikryl Jan 25 '19 at 08:29
  • I removed the unmatched quote, I put in incorrectly . In log file I am getting now : 'psftp' is not recognized as an internal or external command, operable program or batch file. I tried to change command in ssis.bat cd c: c:\ftp\psftp , now getting error : The filename, directory name, or volume label syntax is incorrect. – usama.nomani Jan 25 '19 at 09:30
  • "cd c: c:\ftp\psftp" - Is that one line or two? Do you really have `psftp.exe` in `c:\ftp`? – Martin Prikryl Jan 25 '19 at 09:46
  • In two lines, Yes I do have psftp.exe file in c:\ftp. – usama.nomani Jan 25 '19 at 09:52
  • Where do you see the error? In the `psftp.log`? Do you get the same error, if you run the batch file manually? – Martin Prikryl Jan 25 '19 at 12:57
  • I see error in .log file. When I am running commands manually it is running fine. – usama.nomani Jan 25 '19 at 13:51
  • I've asked you get the problem when running the batch file. Not the individual commands. – Martin Prikryl Jan 25 '19 at 13:56
  • My bad, Yes when I am running the batch file problem comes – usama.nomani Jan 25 '19 at 14:01
  • Then your batch file must have some obvious mistake. What does it look like exactly? 1) `cd c:` 2) `c:\ftp\psftp user11@mftobinternal.com -pw pass**** -be batch -b ssis.bat -hostkey=9b:64:24:b2:0c:56:ab:94:1d:15:80:90:3a:b1:3a:01 > C:\FTP\psftp.log 2>&1` ? ---- `cd c:` is a useless command. You probably wanted `cd /d c:\ftp` – Martin Prikryl Jan 25 '19 at 14:04
  • I solved this out by removing -be Batch . – usama.nomani Jan 30 '19 at 14:57

0 Answers0