3

Is it possible to run a shell script inside a zip folder in Linux? I have a shell script that is saved inside a zip folder, and I'd like to run the shell script inside the zip file (as if the zip file were a directory).

All that I'm trying to do now is run the command ls inside a zip file (so that the command will run inside the zip folder, and run just as if the zip folder were an unzipped folder.)

1
  • @Omnifarious I think I've found a workaround: I suppose it would be easier to write a script that unzips the folder, runs the script inside the folder, and then zips the folder again. Commented Nov 23, 2012 at 16:47

3 Answers 3

9

You asked if it's possible: yes, this is possible if you mount the zip as a filesystem (or, of course, if you unzip the archive, which I'm assuming you're explicitly not willing to do from Some Good Reason).

See Fuse-Zip for a tool that will do this. You could then do something like:

$ mkdir foo ; fuse-zip foo.zip foo
$ foo/running-my-script-in-foozip.sh
...
$ fusermount -u foo ; rmdir foo

Note that this is going to requires fuse, which in-turn requires a kernel module that you may or may not have. But you asked if it was possible, not if it was convenient.

2

There's also a program called AVFS which, as I understand it, doesn't require a kernel module. There's also the perl module Archive::Zip, if you want to roll your own program. (But if it were me, I'd probably write a shell script to extract the archive to a temp dir before running the program instead.)

1

Since you just want to run ls, could by any chance unzip -l or unzip -ll do what you want - list the files in the archive?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .