SSIS Execute process task to copy 2 files into new file - sql-server

Hi i wanted to copy the records of two csv files into a new file.
Task : Copy A + B into C
OR Copy A to B ( this is what i am doing but i don't know how via SSIS)
I used SSIS to do so using Execute Process Task . In order to verify i tried it in command prompt.
When i tried via SSIS package it fails i am not sure why here are the inputs for the executable and the arguement.
Thank you very much in advance

Recommendations:
Don't use \ when assigning a value (only in expressions)
You have to use /C before passing parameters to cmd.exe
Because you didn't specify the Working directory you should provide the full path for each file, if not Out.csv will be created in the package runtime folder.
The command must be like the following:
/C copy /b C:\Temp\Source.csv + C:\Temp\Destination.csv C:\Temp\Out.csv
Reference
Executing Command Prompt commands in SSIS

Related

SSIS Expression builder for MULTI line file ( Exec Process Task)

My global task to create config file for WinSCP process, and it should be multi lines (no options). I try to use Expression builder for CMD/Echo to do this. And still file, tried all option with and without /C flag which is critical for SSIS cmd task. I have option to have task for each line and it's by back plan, but trying to see if I can come up and learn how to do this in single box. I example below I can create multi line Expression using + " " combo where second quotes on new line. But it's still not good for whole task, Looks like CMD /C need single line ??
All info displayed in pic below:
This is arguments I'm using now with WinSCP executable in System task.
open ud12345d264d7b8#magdaflyn.sharefileftp.com
option transfer binary
put c:\SFTP\Magda_Members_20190901.csv "/Business Intelligence Share/Zbignev/"
close
exit
Creating multi-line expression
In order to add new lines in SSIS expression you must use the carriage return and line feed characters \r\n:
"/C Echo line11 \r\n /C Echo " + #[User::Var3] + "Line222 \r\n /C Echo Line3 > Config.dat"
Executing multiple commands
If adding new lines didn't work, you can use && operator to run multiple command using CMD:
SSIS: Execute Multiple Commands with 1 line in Execute Process Task (Arguments)
Workaround
If all what I mentioned above didn't work, then try saving the whole command into a batch file, and execute this batch file from the Execute Process Task.
You can write two lines using this syntax:
/c "echo line1 && echo line2" > config.dat
Though, you do not need to create a config file for WinSCP. All WinSCP options can be configured on its command-line. So this may be XY problem.
And while it's not clear, you may actually be creating a script file, not a config file. You can instead specify all WinSCP commands on WinSCP command-line using /command switch:
winscp.com /command "open ud12345d264d7b8#magdaflyn.sharefileftp.com" "option transfer binary" "put c:\SFTP\Magda_Members_20190901.csv ""/Business Intelligence Share/Zbignev/""" "close" "exit"
WinSCP GUI can generate a command-line sample for you.
See also WinSCP article SFTP Task for SSIS/SSDT.
Though you actually better use WinSCP .NET assembly instead of scripting in SSIS. See Using WinSCP .NET Assembly from SQL Server Integration Services (SSIS).

SSIS Creating a multiline DOS file

I have to create a multiline DOS batch file in SSIS that looks like this:
cd e:\client\data
copy generic_output.txt clientname.yyyymmdd
where yyyymmdd is today's date
I have created quite a few single line DOS copy statements which do the copy (using a Derived column in the Data Flow) but can't come up with an approach that will allow me to create a template file that contains the (hardcoded) first line and then have a Data Flow task which writes out the first line and then have the Derived column be the second line.
Can I write out both commands in the Derived Column and put in a CR-LF in between the cd command and the copy command? Or is there a better approach?
I figured out a way that works. The cd command is fixed so I put that into a file. Then I used a Data Flow to build the COPY command in another file. Then I set up a copy.bat file to copy the 2 files, and then finally an Execute Process task to execute the final batch file. It works.
Thanks,
Dick

F# Script Ends Immediately After Execution (FSI)

When I double-click .fsx files the script ends immediately after execution. There is no chance of interacting with the script or see what it does.
I can barely see one of the scripts create a WinForms window, but it quickly closes.
I have tried several default Run actions (including sending to a .cmd file):
"C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\fsi.exe" "%1" %*
"C:\Program Files (x86)\Microsoft SDKs\F#\4.1\Framework\v4.0\fsi.exe" --quiet --exec "%1"
Both command lines you tried do indeed run the script and then exit. If you want to keep the REPL open to interact with the script, you need either --load:file.fsx or --use:file.fsx.
--use:file.fsx does roughly the same as just running fsi and then pasting the contents of file.fsx into the REPL. So for example if the file just contains let x = 2 then you can immediately type x;; and it will be recognized. This is the one you want if your file contains a bunch of values, statements, types and/or modules.
--load:file.fsx does roughly the same as just running fsi and typing #load "file.fsx". This means that values defined in this file will be in a separate namespace. This is the one you want if your file starts with a namespace or module declaration.

quoting for cmd.exe with argument within argument

I've searched in many posts that already deal with this kind of issue but I'm still not able to make it work in my case.
I'm trying to create a link file to Launch a bat file with cmd.exe (because the bat file launch a service in spy/console mode so the console has to be shown).
The bat file is created before the install process of the service.
The link file is created in Windows Start Menu while installing process, so it can embed the path where the exe file of the service is installed.
As the root path will be linked to cmd.exe, I need to pass the path of the exe of the service as an argument of the bat file, itself being an argument of the cmd.exe file...
I've tried the syntax given as a solution in this threat :
correct quoting for cmd.exe for multiple arguments
Spaces in Program Path + parameters with spaces :
cmd /k ""c:\batch files\demo.cmd" "Parameter 1 with space" "Parameter2 with space""
So in my case, I've writen:
cmd /k ""C:\Program Files (x86)\Company\Licenses Server\Debug Mode.bat" "C:\Program Files (x86)\Company\Licenses Server\""
Here is the content of the "Debug Mode.bat" file :
#ECHO off
net stop company.service
START %~f1ServiceFile.exe /console spymode
net start company.service
#ECHO On
But when I launch the link file, I get the message:
Windows cannot find C:\Program...
There must be a "quote" problem but I've tried a lot of different syntaxes and I cannot figure out what goes wrong here...

Batch file to execute redis commands

I am trying to write below commands in batch file.
cd C:\Redis
redis-cli
select 6
file name is "xxx.bat"
It should connects to local redis instance and select database 6.
but it stops at second command "redis-cli". and does not even write second command "select 6"
on command prompt.
I mean i connects to server , but does not write next command.
I think i do not know something about executing commands in batch file.
I can run these commands outside of batch file without any problem.
Can somebody please spot the problem.
Regards
CMD does not pass the commands to the redis-cli.
You can test it with quit from the redis-cli, you will see a a CMD error for the select 6 command.
You should put all of your commands (without connecting with redis-cli) in a text file e.g test.txt and pass it all to to redis-cli. i.e:
type test.txt | redis-cli -x
p.s. there's no need to specify .exe or any other extension that is in you %pathext% variable, but it makes your scripts more readable.
Try
cmd /c "redis-cli select 6" >> output.txt
I need to specify exe with the command.
redis-cli.exe select 6
With my redis 2.4.6 on windows you can pass the command as an argument to the redis-cli executable. Here is my windows batch file:
SET REDIS_PATH=E:\Program Files\Redis
"%REDIS_PATH%\redis-cli" select 6
Of course you would change the redis path variable to wherever you have copied / installed Redis to.
Here is the output from running the windows batch file:

Resources