Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.)

share|improve this question
    
Why do you want to do this? –  Omnifarious Nov 23 '12 at 8:19
    
@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. –  Anderson Green Nov 23 '12 at 16:47
add comment

3 Answers

up vote 4 down vote accepted

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.

share|improve this answer
add comment

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.)

share|improve this answer
add comment

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?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.