Redirect output with ">>" doesnt always work? - redirect

i have such problem. When i use command for 7zip:
7za a -t7z file.7z file.iso
i see in console dynamically changing output like this:
7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Creating archive file.7z
Compressing file.iso 12%
When i redirect output to file with command:
7za a -t7z file.7z file.iso >> file.txt
Im just getting final message:
7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Creating archive file.7z
Compressing file.iso
Everything is Ok
Why? I want all messages. What am i doing wrong?

it all is ok, I'm using exactly the same 7zip version under current stable debian 7.1 64bit.
7zip detects, stdout is assigned to terminal or not. when not to terminal, this in the background use option -bd , disable percentage indicator. developer assumes that you read log post factum, and do not analize output on the fly.
unfortunately it is not possible switch on percentages on the file. you can only switch off percentages on the screen.
what for you need % in log file.txt ?

Related

7 zip command line equivalent to the explorer extension

I am looking for the 7-zip command line call that is the equivalent to the explorer extension option of Add to "FolderName.zip":
I have tried:
& 7z C:\path\To\SecondAttempt, C:\path\to\SecondAttempt.zip
And I get the following
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
Command Line Error:
Unsupported command:
C:\path\to\SecondAttempt,
Does anyone know the command line equivalent of the explorer extension for 7-Zip?
The shell extension invokes 7zG.exe, a GUI utility that shows a nice GUI window if this is what you were looking for. Using SysInternal ProcMon it's possible to look up the command line used, basically:
& "C:\Program files\7-Zip\7zG.exe" a -tzip -slp- "a.zip" "file1.txt" "file2.txt"
The file list can be put into a file and its name is specified after # instead of the file names.
-slp- disables large page mode, and -slp enables compression speedup of large files
Fo 7Zip this should be the correct syntax
. .\7z.exe a C:\path\to\SecondAttempt.zip "C:\path\To\SecondAttempt"
But I would prefer to use directly .NET
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::CreateFromDirectory("C:\path\To\SecondAttempt","C:\path\to\SecondAttempt.zip")

Command line 7zip issues when encrypting headers

I'm creating an zip file using 7zip from the command line during my build process. using a command like this:
7z.exe a -pPassword "..\sot.zip" .
This command works correctly and I'm able to see an encrypted file as expected. Now when I add the capability to encry0pte the headers
7z.exe a -mhe=on -pPassword "..\sot.zip" .
7z.exe a -mhe+ -pPassword "..\sot.zip" .
7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Creating archive sot.zip
System error:
The parameter is incorrect.
I get "The parameter is incorrect." errors regardless of where I put them on the command line.
Is there a way to perform the encryption of headers from the command line.
-mhe is not supported in .zip files. For it to work, use .7z format
7z.exe a -mhe=on -pPassword "..\sot.7z"
I did this, and it did work:
7z.exe a -psecret -mhe=on C:\newfolder\a.7z "C:\folder1\back-this-up"

How do I silently install a 7-zip self-extracting archive to a specific directory?

The Ruby Devkit is a 7-zip based self-extracting archive.
I would like to invoke it silently without having to install 7-Zip to extract the files to a folder of my choosing, so that I can script the installation. I imagine it to be something like:
cmd> DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe /silent /dir="C:\DevKit"
But that, of course, doesn't work. What command line flags must I use to silently extract this archive into a folder of my choice?
try this:
C:\> DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe -o"C:\DevKit" -y
Update 2017: The tool from 7zsfx.info is now dead and gone.
Original, old post from 08-2015:
If you are trying to extract an 7zip SFX (http://7zsfx.info/) archive:
sfx.exe -y -gm2 -InstallPath="C:\\your\\target\\path"
Switches Docu
-y hide some prompts
-gm2 hides the extraction dialog completely (silent mode)
-InstallPath sets the target path (you need double backslashes)
7z SFX Guide
The official way to create a SFX package is to use -sfx[{name}] : Create SFX archive.
And that means the created SFX packages uses two kinds of CLI options:
official CLI options from 7zSFX, and
the passed through options you configured in your config, before creating the package.
You can think of it as parameter forwarding to the packaged executable. This parameter forwarding depends on the SetEnvironment and RunProgramm configuration!
The full process:
Create archive Package.7z:
containing Installer.msi and additional crap.cab file.
Create config file config.txt:
;!#Install#!UTF-8!
Title="Installation"
SetEnvironment="strInstall=hidcon:Installer.msi /qn"
RunProgram="%strInstall%"
;!#InstallEnd#!
Now we generate Test.exe by combining sfx+config+archive into an executable.
copy /b 7zS.sfx + config.txt + Package.7z SfxInstaller.exe
Note: 7zS.sfx is from the official 7zip extra package.
Now, when you run SfxInstaller.exe you can pass for instance /lv InstallerLog.txt to create a install log, e.g.
SfxInstaller.exe /lv InstallerLog.txt
Since 7-zip is used, simply create a self-extracting archive in .exe. and run it with switches -o and -y.
I use it to save space on USB drive. For instance, I run VDiskAir application infrequently. I create a self-extracting archive of the VDiskAir program folder (about 15MB):
7z a -SFX -mx9 VDiskAir.exe [VDiskAir folder path]
NB: -mx9 is used here to maximise compression.
I create a DOS BAT to run the self-extracting VDiskAir.exe (about 5MB) created, save it as VDiskAir.bat containing:
VDiskAir.exe -o%TMP% -y
%TMP%\VDiskAir\VDisk_Air.exe
I'm not worried that the VDiskAir folder (in %TMP% extracted with VDiskAir program files) is undeleted after running VDiskAir this way, since I have a BAT script to clear %TMP% on shutting down/starting up.
Below is what I use for Autodesk product:
Start /W %~dp0AutoCAD_2018_French_LP_Win_64bit_dlm.sfx.exe -suppresslaunch -d C:\Autodesk

print via system() in perl via xampp (windows-7-x64) not working

I need to print a generated text-file with perl. I'm using xampp, Windows7 64 bit.
My perl-script is containing the print system call:
$system = "print\ /d:\\\\SERVER\\PRINTER\ C:\\xampp\\cgi-bin\\textfile.txt";
system ($system);
When i try the same line in the cmd-shell, the print works.
The answer is:
C:\xampp\cgi-bin\textfile.txt wird momentan gedruckt.
but nothing else happens.
I then tried to create a batch-file. Starting the batch-file manually starts the print. From a system()-call nothing happens.
Then i tried another way, showing the file in Firefox first. I copied the file to my htdocs-dir and changed my batch-file to:
cd "c:\Program Files (x86)\Mozilla Firefox"
firefox.exe -new-window http://localhost/textfile.txt
Doubleclicking the bat starts my firefox and my textfile.
The system()-call ist not working.
Any Ideas?
Tom
My brother found the reason. THANKS CHRIS!
It was a problem with the permissions.
The apache service is running without normal user permissions.
To set user permissions (or, better: special defined, new permissions) in Windows 7 pro 64 bit:
(Sorry, this is german)
Task-Manager
"Dienste"
rechts unten auf "[Adminzeichen] Dienste"
Auf Dienst "Apache" rechtsklick "Eigenschaften"
Reiter: "Anmelden"
Auswahl: "Dieses Konto"
User und Passwort rein
"Übernehmen" und "OK"
Dann nochmal auf "Apache" linksklick und links auf "neu starten"

How to extract ZIP files with WinRAR command line?

While trying to extract zip files I get the error:
c:\path\name.zip is not RAR archive
No files to extract
My code is:
p.StartInfo.FileName = #"C:\Program Files\WinRAR\rar.exe";
p.StartInfo.Arguments = string.Format("x -o- {2} \"{0}\" * \"{1}\"\\ ",
szFN,
outFolder,
passWord == null ? "" : string.Format("-p\"{0}\"", passWord));
The GUI version can extract zip and 7z files.
Why doesn't this work? How can I extract zip and 7z files?
(NOTE: I have different source code for 7zip. I guess I can merge the two and only use the above when the file has a rar extension. But I don't like that solution.)
Free unrar.exe and console versionRar.exe of WinRAR support only RAR archive format. That is clearly described in second paragraph in manual for Rar.exe which is the text file Rar.txt in program files folder of WinRAR.
You need to use WinRar.exe instead which supports also other archive formats:
[path\winrar.exe] x [switches] [path to zip file] [files to extract, . for all files] [path folder to extract to]
Example:
"%ProgramFiles%\WinRAR\winrar.exe" x -ibck c:\file.zip *.* c:\folder\
The syntax, commands and switches for GUI version WinRAR.exe are listed and described in help of WinRAR. Click in menu Help on menu item Help topics, open on help tab Contents the item Command line mode and read the help pages listed under this item.
For example the switch -ibck supported only by WinRAR.exe but not by Rar.exe is for running the extraction in background which means GUI version of WinRAR makes the extraction minimized to an icon in Windows system tray.
rar.exe can indeed only unpack rar files. It's not at all the same as WinRAR.
For unpacking ZIP files in .NET, you might want to look at the DotNetZip library instead. It has a license compatible with commercial software, unlike CSharpZipLib.
If you need to support RAR as well, you can use UnRAR.dll with pinvoke:
http://www.rarlab.com/rar_add.htm
http://www.rarlab.com/rar/UnRARDLL.exe
Or this .NET unRAR libary:
http://www.chilkatsoft.com/rar-dotnet.asp
Perhaps this one for 7zip.
You can use either SevenZipSharp or DotNetZip Library in your Application!
But I will go for SevenZipSharp Lib as It supports all the archives supported by 7-Zip!
Both Source and Binary are available in the Links!
for /f "tokens=*" %G in ('dir /on /b "D:\BACKUP_DATI\EXCEL\OPER*.ZIP"') do "C:\Program Files\7-Zip\7z.exe" x "..\%G" –aoa
References to further reading:
7-Zip command line examples
FOR /D - Loop through directory