SSIS: Execute Process task can't execute FTP - sql-server

i'm trying to transfer my data from TXT that i generate in a Data flow task to FTP library and can't do it
If i use Execute Process Task i must execute a File1.bat:
#echo off
ftp -s:fileName.txt -n
and fileName do it:
open
172.16.60.223
user
username
password
put \\dappwstd2008\paso\Esteban_Entregas\Clientes\fileName.txt BICCONVER1/CVCUREL
close
bye
If i execute the file1.bat works correctly, but can't do it with SSIS.
i tried to do the following:
Execute Process Task
Executable: D:\Users\MyName\Desktop\file1.bat
Argument: "fileName.txt"
[Execute Process Task] Error: In Executing
D:\Users\EDonosoV\Desktop\file1.bat" ""fileName.txt"" at "", The
process exit code was "2" while the expected was "0".
i change success value to 2 and work but CMD do nothing
Any solution?, i tried using the code of the TXT in FTP Task and have problem with RemotePath because my destiny is a library and can't open it
Thanks!

Try copying your filename.txt into C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn (If you are using SSIS 2010)
Similar path for 2008 or 2014
This is the "Working Directory" when you run BIDS
Or just fully qualify the path

I solved it!
i must write the route of the folder with .bat and .txt inside in Working Directory
Executable: D:\Users\MyName\Desktop\file1.bat
Argument: "fileName.txt" (This file inside Desktop or the same folder of file1.bat)
Working Directory:D:\Users\MyName\Desktop\
And work it, transfer my Flat file to FTP!
Thanks for the comment and i hope help someone else with the same problem!

Related

.vbs script runs in batch file but not when run through task scheduler

I have a batch script with 4 commands as follows
sqlcmd (truncate table in database)
del "path to existing csv to delete"
"path to my .vbs script" "file path to xls file to convert" "file path to where csv is to be created"
"File path to Python" "File path to python script to read csv into database"
It runs just fine when I double click the batch file. When I try to run the batch file from the command prompt it doesn't see the .csv file to delete, I'm not sure why this is, but I don't think it matters for my purposes.
When I run the task from task scheduler manually it truncates the table in the database and deletes the existing csv file but the new one is not created which leads me to believe it is getting stuck on the .vbs file.
I have tried making an individual task with the .vbs script and passing in the path to the .xls and .csv files as arguments, but again it just runs without stopping.
I have tried adding
#echo off
>log.txt(
the body of my batch script
)
but nothing gets written to the log. I have also tried adding cscript and also tried adding wscript at the beginning of the line in the batch file which calls the .vbs script and have tried changing the start in directory to C:\batch where the file resides.
No luck with any of the above attempts. Not sure where to go from here.
Found this 2013 answer by eric on Superuser:
Create these two folders:
32Bit:
C:\Windows\System32\config\systemprofile\Desktop
64Bit:
C:\Windows\SysWOW64\config\systemprofile\Desktop
Excel needs these folders if it's not run interactively. Create both folders even if you are on a 64-bit OS.

Executing WinSCP command in batch file

I am new to batch and trying to execute a script I wrote, essentially I want to go to a remote server copy the files there and transfer it to a folder in my local directory. I am executing the bactch file but nothing is being copied any suggestions would be great. This is my script
open sftp://site:#ftp.site.net -hostkey="server finger print"
synchronize local C:\Users\localdirectory\Desktop\test2 /Home/folderA/NewFiles
exit
I am positive all the information is correct because that's how I login with WinSCP. I got this script from https://www.youtube.com/watch?v=ndvEYOQLc4c
This is WinSCP script. There's no batch file in your question.
To run WinSCP script, use for example:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /script="C:\path\to\winscp.txt"
(assuming your WinSCP script is in C:\path\to\winscp.txt).
You can put the above command to a batch file.
See guide to scripting with WinSCP.
You can also have WinSCP GUI generate both the script and batch file for you (or even a batch file that directly contains the WinSCP commands).

Ignore Error Code 2 PSFTP

We have an desktop application that dynamically generates a command file to pull specific files that have the current date in the name. So in the end we have a command file that looks like this:
lcd e:\localpath
mget Filename0111.dat
mget Filenametwo0111.dat
mget Filenamethree0111.dat
bye
Where 0111 is MMDD. The command file is created via a .bat file that the desktop app executes. The application then connects to the remote server via PSFTP.exe and runs that command file to pull files.
The problem we're running into is we updated the PSFTP.exe to a newer version due to a separate issue that occurred. Now if a file is not available on the remote server it returns an error code 2 which stops the rest of the files from being retrieved. So if the first file in the list doesn't exist then it fails and the rest of the files are not downloaded.
Is there a way to ignore the error code 2 so that the rest of the files get retrieved? I had thought at first to run PSFTP.exe and it's commands through a batch file but that didn't work.
Any ideas?
PSFTP.exe has a command -be that will continue executing the batch if there is an issue.
When running a batch file, this option causes PSFTP to continue processing even if a command fails to complete successfully.
You might want this to happen if you wanted to delete a file and didn't care if it was already not present, for example.

How to Run SSIS Package Using Task Scheduler and Batch File

I have a windows batch file that looks like this:
"C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\DTExec.exe" /FILE
C:\SSIS\CARS\CARS\PCarsCallMonthlyCount.dtsx /DECRYPT pswrd /CHECKPOINTING OFF
When I run code from the command prompt the SSIS package runs with no errors. I then created a scheduled task to run and call the same batch file. The task runs but does not error out or end.
So I then open the batch file from the command prompt and I get this error "Missing argument for option "file". The execute Package Utility application then starts and waits for some input.
So I assume I am missing something in the command and that is why the task does not complete. How can I fix this?
If the command line is exactly how you have it in the batch file, you need to make it all on one line. It is not getting the second part of /FILE which is your .dtsx file.

FTP batch script is not exiting with error status

There is a ftp command in my batch script :
FTP -n -s:D:\scripts\Test\get.ftp
Where get.ftp contains all ftp commands including "mget abc*".
Issue here is when file(s) of names starting with abc* is not available, mget is not failing. Also, if any other ftp command fails also, the script is not exiting with error status 1. i.e. "FTP -n -s:D:\scripts\Test\get.ftp" exiting without issues.
Not able to make the batch script fail when there is no file to pick up.
Need suggestion if someone has faced similar issue.
-Krishna
The mget command works by obtaining a remote folder listing and parsing the list for the wildcard pattern that you provide. As long as the listing can be obtained successfully,
it is not considered an error if your pattern did not match any of the files on the list.
Your batch script can be setup to compare the local folder listing before and after invoking the ftp command to check if a file was downloaded. You can also use a scripted ftp solution like kermit or ftp script to be able to have more control on error reporting.

Resources