7-Zip throws an error in SSIS 2012 - ssis

I have the following problem:
I use 7-Zip in my SSIS 2012 package.
So I created the Execute Process task and put there:
WorkingDirectory: C:\Program Files\7-Zip\ (it's correct, double checked it)
Executable: 7z.exe
Argumnets: e "C:\Data\B1\Arch.7z" -so > "C:\Data\B1\Arch.7z.dat"
It means that I want to put all unzipped data to the file (stdout) Arch.7z.dat.
When I run the package I got the following error:
Cannot use absolute pathnames for this command
This error is thrown by 7-Zip.
But when I run the same command from command line it work correctly:
C:\Program Files\7-Zip>7z.exe e "C:\Data\B1\Arch.7z" -so > "C:\Data\B1\Arch.7z.dat"
What is the problem there?
Thanks
Mik

The -o switch specifies the output folder and has to be used in addition to specifying the path in the -so switch. Specifying only the -o switch without the full path in the -so redirect or only the full path in the redirect without the -o switch won't work as expected or at all.
It should look like this:
C:\Program Files\7-Zip>7z.exe e -oC:\Data\B1 C:\Data\B1\Arch.7z -so > C:\Data\B1\Arch.7z.dat

Try something as follows.
Executable C:\Program Files\7-Zip\7z.exe
Arguments e “C:\Data\B1\Arch.7z”
Working directory <Path of your source file>
Take a look at the following example.
Example to Unzip using 7 Zip in SSIS
Hope this helps!

Related

Problem with the command-line JSON processor JQ in Windows 10, 64 bit

I have downloaded the program jq-win64.exe from 'https://stedolan.github.io/jq/' and installed the program in a folder C:\Program Files\jq\ on my computer.
I have also added the PATH to the program to the end of the systemvariable string in Windows 10 : . . . ;C:\Program Files\curl\;C:\Program Files\jq\
In one terminal window in Visual Studio Code I am running a server.
In another terminal window I am trying to execute the command curl -s localhost:3000 | jq
Terminal window 1:
C:\Users\SteinarV\PROFF_JAVASCRIPT\PROJECT\smartHouse
node server.js
API running on port 3000
Terminal window 2:
C:\Users\SteinarV\PROFF_JAVASCRIPT\PROJECT\smartHouse>curl -s localhost:3000 | jq
'jq' is not recognized as an internal or external command,
operable program or batch file
... and do not understand why jq is not recognized.
Can someone help ?
I have downloaded the program jq-win64.exe from 'https://stedolan.github.io/jq/' and installed the program in a folder C:\Program Files\jq\ on my computer.
As you have indicated, you have a file called jq-win64.exe but you are trying to execute the command jq. You either need to rename the file to jq.exe or you need to use the command jq-win64.
For a detailed explanation of how Windows finds and executes a program in your path when you enter a command, see The Windows NT Command Shell: Command Search Sequence. Specifically:
...The shell now searches each directory specified by the PATH environment variable, in the order listed, for an executable file matching the command name. If a match is found, the external command (the executable file) executes...
...If the command name does not include a file extension, the shell adds the extensions listed in the PATHEXT environment variable, one by one, and searches the directory for that file name. Note that the shell tries all possible file extensions in a specific directory before moving on to search the next directory (if there is one)...
You indicate in the comments the same error persists even when the filenames match. Note that each running program has its own set of environment variables, and these aren't updated by global changes. You need to close and reopen cmd.exe windows after making a global change. See also Adding directory to path environment variable in windows. You can use the path command to verify whether a particular terminal session has inherited the PATH variable you defined, thus narrowing your problem.
You indicate that the problem still persists. You need to use the tools available to you to narrow it down further:
Try running the program with its full path:
"C:\Program Files\jq\jq-win64.exe" --help
This will confirm that the program is present where you think it is and can be run from the terminal.
Try running the program with no path and its extension:
jq-win64.exe --help
If this works but running the program without an extension doesn't, you might have set PATHEXT to something that doesn't include ".EXE".
Try setting the path explicitly in the terminal to contain only the program directory and nothing else, then run it with its full extension:
set PATH=C:\Program Files\jq
jq-win64.exe --help
(Note that after this test you'll need to close the terminal window and start a new one to reset the path.)
If this works, perhaps you have a mismatch in your path.

how to unzip rar files which are in remote server using ssis task

I have .rar files in network folder and I need to unzip rar files and store as .bak files into remote server. I have used execute process task and passed expressions but when I am executing task getting error as The process exit code was "2" while the expected was "0".
I have googled the error but did not find how to fix this. Please can anyone suggest me how to do this.
Below are the expressions I used
Executable : C:\Program Files\7-Zip\7z.exe
Arguments : x \\NETWORK-SQLBACKUP\ACCOUNTS\Monthly\CustomerDB\CustomerDB_backup_2015_08_31_203001_4545366.rar -o\\SDL-VR-DBSBACKUP\F:\Monthly bak files\CustomerDB_backup_2015_08_31_203001_4545366
Thanks.
7zip, error code 2 means 'fatal error'.
You may need to wrap the output file in quotation marks because it contains spaces.
A good way to test it is running it from the command line manually and make sure it works, once you are happy with the result you can try it from a SSIS task.:
"C:\Program Files\7-Zip\7z.exe" x \\NETWORK-SQLBACKUP\ACCOUNTS\Monthly\CustomerDB\CustomerDB_backup_2015_08_31_203001_4545366.rar -o"\\SDL-VR-DBSBACKUP\F:\Monthly bak files\CustomerDB_backup_2015_08_31_203001_4545366"

Error: Command failed: C:\Windows\system32\cmd.exe /s /c “rm ./mean/package.json”

How to fix this error. When i use command “yo meanjs”, but not show as in video. It’s:
undefined
You’re using the official MEAN.JS generator.
What mean,js version would you like to generate? i choose 0.4.0
In which filder would you like the project to be generated? mean
Cloning the MEAN repo…
Then it appear error:
Command failed: C:\Windows\system32\cmd.exe /s /c “rm ./mean/package.json”
‘rm’ is not recognized as an internal and external command, operable program or batch file.
you should install git on windown 7 and select folder you want . click -> right mouse -> Git Bash
After type command : "yo meanjs" and everything will good
The tpt2213's answer works, but it can't select menu items of "yo meanjs" with arrow keys.
You need to have cmd.exe with PATH setting, which includes the git command and Unix commands like the rm.
If you install git on window 7 in the folder, "C:\Program Files\Git", set PATH before you run "yo meanjs".
set PATH=C:\Program Files\Git\usr\bin;C:\Program Files\Git\bin;%PATH%
yo meanjs

How to fix exit code issue while using WinSCP for SFTP from within SSIS package?

I am using SSIS 2005 to do some SFTPtasks using WinSCP. I googled about the error but couldn't make it work. I got this error:
[Execute Process Task] Error: In Executing "C:\Program Files\WinSCP\WinSCP.exe" "-script=C:\Documents and Settings\nian_z\Desktop\temp\SSISMovingSOA\removeSOA8.txt" at "C:\Program Files\WinSCP", The process exit code was "1" while the expected was "0".
Here is my WinSCP script that I use:
option batch abort
option confirm off
#open sftp://user:password#server:22
#cd /m/vo/Cont/fileftp
get OrderOutbound*
close
exit
For above script, I even tried leaving only one statement at a time, but still got error.
Here is the setup of the execute process task.
This is not an answer but an attempt to help you find a solution to your problem.
Try this:
Try the following steps to find out if your script is actually working outside of SSIS or not.
Click Windows Start and click Run...
Type cmd to open Command Prompt.
On the command prompt window, type the following command at the prompt to switch to the WinSCP installation directory. I have the WinSCP installed in the following directory. Change the path according to your environment settings.
cd "C:\Program Files (x86)\WinSCP"
If your WinSCP script file removeSOA8.txt is located in the path C:\Documents and Settings\userid\Desktop\temp\SSISMovingSOA\ with spaces, then type the following command by enclosing the script path in double quotes to run the script and also use the /log option to capture all the status messages.
WinSCP.exe "/script=C:\Documents and Settings\userid\Desktop\temp\SSISMovingSOA\removeSOA8.txt" /log=C:\temp\WinSCP_log.txt
After the script executes, your will find that a log file named WinSCP_log.txt will be created in the path C:\temp. Read through the file to identify if there are any error messages.
Attempt to run FTP in SSIS:
I tried downloading a file from FTP using WinSCP with the following script:
option batch abort
option confirm off
open ftp://myuserid:mypassword#ftp.myftpsite.com:21 -passive=on
cd /root/somefolder/
option transfer binary
get SomeFileOnFTP.txt c:\temp\
close
exit
Here are the settings how I have configured the Execute Process Task within the SSIS package.
The process ran successfully in BIDS.
Hope that gives you an idea.
If you are running the script from SQL Server job agent then mostly you will get this exit error.
Scenario: In my case I faced when i m trying to download a file from sFTP server.
Solution :
Step 1 - Create a batch file
#echo off
CD "C:\Program Files (x86)\WinSCP"
winscp.com /ini=nul /script=C:\path\download_script_pm.txt
Exit
Note: When calling using SQL Server Job agent make sure to NULL out the “ini” configuration else it will throw up this error
Step2 – create a txt file (winscp script)
option echo on
option batch on
option confirm off
open sftp://user:password#sftp.xxxx.com/ -hostkey="ssh-edXXXX-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx-xx"
option confirm off
get -filemask=">=1D" /sftp_Path/File_Name_.csv
C:\local_path_for_downloaded_file\"
exit
Note: make sure to use hostkey. To obtain host key you need to do the following :
1. Open winscp app tool and login to the server
Click Session -> Generate Session / URL code option
Check SSH Host key and copy the finger print value and use in the winscp hostkey value
Earlier I was getting the same error but now is working fine for me.
SSIS Execute Process Task :
Executable - C:\SSIS\SSIS_2008_Projects\HRIS_RepomanFusion_Load\WinSCP\WinSCP.com
Arguments - "/script=wscpBatchTest.txt" /log=C:\SSIS\SSIS_2008_Projects\FTP_Load\WinSCP\WinSCP_log.txt
Working Directory - C:\SSIS\SSIS_2008_Projects\HRIS_RepomanFusion_Load\WinSCP
Here is the WinSCP script that I use: wscpBatchTest.txt
option batch
option confirm off
open sftp://username:password#ftp.test.com
option transfer binary
cd /home/SAFAA
get employeedetails.csv C:\SSIS\SSIS_2008_Projects\SAFAA\InputDirectory\
close
exit

Unzip a Password Protected file in SSIS

I have problem with Unzipping a Password Protected file in a SSIS Package.
I Always use Execute Process task But this time After the package download zip file from ftp it must unzip it then i use it as flat file.
now the problem is i can't unzip the file cause its password protected.i have the password of file but i don't now how to use it.
is there a command line or some thing?
You need to find a command-line tool that can unzip password protected zip files, then you can use the Execute Process task as usual. If you don't want to hard-code the password into the SSIS package, you could put it in a package variable, populate the variable from a package configuration or a dtexec parameter, and then set the properties of the Execute Process task dynamically.
Finally find it...
use a execute process task and set parameter as below:
executable : C:\Program Files\WinRAR\WinRAR.exe.....(winrar location)
Arguments : e -o+ -ppassword "filename"........i.e e -o+ -p12345 "D:\TRFolder\TR0426.zip"
Working Directory : D:\TRFolder ....... UnzipPath
peace
I got it which actually worked for me.
We need to pass some parameter in the Execute Process task Editor
executable: C:\Program Files\7-Zip\7z.exe [ Source where 7z is installed file]
Arguments: here we have to pass source, password (if any) & destination. followed by e(i.e extract)
For example:
e "D:\App\File\TextDoc.7z" -p1234#Abcd -oD:\App\File\Extract * -r
Here
e means extract
Source: D:\App\File\TextDoc.7z
password: 1234#Abcd
Destination: D:\App\File\Extract
r: this is for Read. means the extracted file file will be visible while extracting