Zip folder created by shell script not opening - shell

I am using the below script to zip the folder and it contents :-
cd /home/fs/Inbnd/
pwd
tar -cvf Image_test_new.zip Image
chmod 777 *
chown fusionc:staff *
The file image.zip is getting created successfully. But the file is not opening and showing an error :
Is there an error in the ststement I am using to zip?

tar -cvf makes a tar ball, not a zip archive. You can verify this in Linux, before trying to open it in Windows.
touch not_going_to_be_a_zip
tar -cvf not_really_a.zip not_going_to_be_a_zip
unzip not_really_a.zip
Archive: not_really_a.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of not_really_a.zip or
not_really_a.zip.zip, and cannot find not_really_a.zip.ZIP, period.
The zip utility does a good job at making zip archives.
touch will_be_a_zip
zip i_am_a.zip will_be_a_zip Archive: i_am_a.zip
testing: will_be_a_zip OK
No errors detected in compressed data of i_am_a.zip.
unzip -t i_am_a.zip
Archive: i_am_a.zip
testing: will_be_a_zip OK
No errors detected in compressed data of i_am_a.zip.
Note: unzip -t will test the archive only, make sure its okay before trying it in Windows.

If you cannot use the standard approach like zip/unzip and if you have JDK installed on your machine then you can use the jar utility from JDK's bin folder.
To zip a file
jar cvf zip_file_name.zip image.jpg
The only overhead is that it will add a META-INF folder with a file named MANIFEST.MF in it, which you can delete after extracting the zip file.

Try to use zip command instead of tar command.

Related

zip -r with ~/ partially replicated my system directory

I am trying to zip my nw.js application into a zip file. So I run this:
"win.sh" 3L, 121C
cp ~/nout/package.nw ~/nout/win/QuantumPilotWin/package.nw
zip -r ~/nout/QuantumPilotWin.zip ~/nout/win/QuantumPilotWin
I expected the zip file to be of a single folder, that of QuantumPilotWin
instead I get this structure:
How do I zip without the full path?
EDIT:
Trying Joe's steps I got this in the unzipped folder:
Run the zip -r command when you are in ~/nout/win/, so:
cd ~/nout/win/
zip -r ~/nout/QuantumPilotWin.zip QuantumPilotWin

move files to .zip archive in windows command line

I wanted to know how to move files to a .zip archive. I'm using this code: xcopy C:\Folder C:\AnotherFolder\zippedFolder.zip. This copies the files from C:\Folder DIRECTLY into the archive, but I want to have that file in the archive (so i can doubleclick the archive and see the file unopened).
Want to do this to create an excel file with a .cmd
Use -m to import a file to a ZIP archive.
I found this on StackOverflow maybe it helps you.
How to move a file in to zip uncompressed, with zip cmd tool
But be careful it deletes the source file after it adds it to the archive. See the link for more details.
UPDATE
Instructions from this site. http://linux.about.com/od/commands/l/blcmdl1_zip.htm.
-m moves the specified files into the ZIP archive; actually, this deletes the target directories/files after making the specified ZIP archive.
If a directory becomes empty after removal of the files, the directory is also removed. No deletions are done until zip has created the archive without errors. This is useful for conserving disk space, but is potentially dangerous so it is recommended to use it in combination with -T to test the archive before removing all input files.
zip -m yourfile zip.file

tar extracted archive removes version

I have a zipped archive version 0.0.1: myarch_0.0.1.tar.gz
When I extract it with tar, everything is unzipped and extracted in a myarch folder, stripping the version number.
ls
myarch_0.0.1.tar.gz
tar -zxvf myarch_0.0.1.tar.gz
ls
myarch/ myarch_0.0.1.tar.gz*
I want the extracted folder to be named: myarch_0.0.1/
How do I keep my version number stuck to the extracted folder name?
The name of an archive file, and the name of the files inside, have nothing to do with each other in general. If you want extracted directories to have a certain name, with a version number, then you have to create the archive with so named directories.
In this example, the extracted content is a directory named myarch, instead of your desired myarch_0.0.1. You can rename the directory and recreate the archive:
mv myarch myarch_0.0.1
tar zcf myarch_0.0.1.tar.gz myarch_0.0.1
That's it. When you untar this new archive, you will get a directory named myarch_0.0.1, simply because that's what you put inside. Even if you rename this file to mickeymouse.tar.gz, when you untar it, you will still get a directory named myarch_0.0.1, simply because that's what's inside the archive. Nothing to do with the filename of the archive.

"End-of-central-directory signature not found" when unzipping

When I unzip the file by double click I get the error
2:no such file or directory
After that I open terminal and use the below command but I get the below result:
unzip /Users/mahesh/Desktop/maheshapp.zip
Archive: /Users/mahesh/Desktop/maheshapp.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of /Users/mahesh/Desktop/maheshapp.zip or
/Users/mahesh/Desktop/maheshapp.zip.zip, and cannot find /Users/mahesh/Desktop/maheshapp.zip.ZIP
Try below command on terminal.
ditto -x -k source.zip Destination_Dir
ditto will recover most of the contents. Credit goes to http://ask.metafilter.com/157754/Mac-OS-X-Recovering-a-corrupted-zip-file
I had this error message and the only solution for me was to install the trial of WinRAR and use that. The zip file wouldn't extract using either the built-in Windows 10 or MacOS extraction utilities.
you have splitted binaries, like file.zip.001, file.zip.002 ... you may just need to combine the files e.g. using cat command: cat file.zip.* > single.zip
Credits: https://superuser.com/questions/365643/how-to-unzip-split-files-on-os-x/1067907?newreg=5fb5d89c2d2a4ae5aeb1842dd233b8d1
I got the same error when my linux run out of space:
[root#client actimize429]# unzip ais-linux-setup-4.29.0.9-20200616.090151-1.zip
Archive: ais-linux-setup-4.29.0.9-20200616.090151-1.zip
End-of-central-directory signature not found. Either this file is not
a zipfile, or it constitutes one disk of a multi-part archive. In the
latter case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of ais-linux-setup-4.29.0.9-20200616.090151-1.zip or
ais-linux-setup-4.29.0.9-20200616.090151-1.zip.zip, and cannot find ais-linux-setup-4.29.0.9-20200616.090151-1.zip.ZIP, period.

View package content created with productbuild

I created a pkg file with the productbuild utility and I'd like to see its content. How can I do that?
I'm under MacOS 10.9.5.
You could extract your package into temporary directory with pkgutil.
pkgutil --expand pkg-path dir-path
Expand the flat package at pkg-path into a new directory specified by dir-path.
There is also very good third party tool called Pacifist, by CharlesSoft. You can view the contents of the package without extracting it.
Update
Inside pkg archive (which is a xar archive) you may encounter following files:
Bom: Mac OS X bill of materials (BOM) file
The Mac OS X Installer uses a file system "bill of materials" to determine which files to install, remove, or upgrade. A bill of materials, bom, contains all the files within a directory, along with some information about each file. File information includes: the file's UNIX permissions, its owner and group, its size, its time of last modification, and so on.
Also included are a checksum of each file and information about hard links. [man bom]
You may list the contents of bom file with lsbom command. And create the file with mkbom.
PackageInfo: XML document text
This xml file contains general information about the package.
Payload: gzip compressed data, from Unix
This is a gziped cpio archive. You may extract its contents to current directory with tar command:
$ tar -xf Payload
Or extract to specified directory dir-path:
$ tar -C dir-path -xf Payload
Optionally you may only list the contents of the Payload archive with:
$ tar -tf Payload
You should be able to recreate the archive from dir-path with:
$ tar --format cpio -czf Payload dir-path

Resources