LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to edit a readonly zip file using vim? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-edit-a-readonly-zip-file-using-vim-4175591456/)

P.G.Krish 10-15-2016 08:00 AM

How to edit a readonly zip file using vim?
 
I tried to edit a zip file and change its content using the following commands
Code:

:set modifiable
:%s/xxA/..\//g
:x!

But it returned the following error
Quote:

W10: Warning: Changing a readonly file
55 substitutions on 10 lines
Press ENTER or type command to continue



I tried to edit a zip file and change its content using the following commands

:set modifiable
:%s/xxA/..\//g
:x!

But it returned the following error

W10: Warning: Changing a readonly file
55 substitutions on 10 lines
Press ENTER or type command to continue

After I pressed Enter nothing changed. Please guide me to solve this problem.

jpollard 10-15-2016 10:54 AM

A read only file is an attribute of the file. You can read the file (which is what vim did), you can make changes (which vim did), but you CANNOT write the file.

What you usually do is write to a different name.

Now a zip file has compressed contents. You really can't edit the contents without first decompressing what you are going to edit. The result of "editing" a zip file is usually garbage. Unusable by zip to decompress (the checksums/decompression fails), meaningless for any use.

P.G.Krish 10-15-2016 11:25 AM

But It possible from this tutorial,https://blog.silentsignal.eu/2014/01...-upload-unzip/

jpollard 10-15-2016 11:33 AM

Quote:

Originally Posted by P.G.Krish (Post 5618382)

So you are creating a trojan?

The problem is still that the access rules to the file forbid changing the file. Change the access rules first.

P.G.Krish 10-15-2016 11:46 AM

No, I dont want to create trojan . Anyway how to change the access rules. I already change it permission. But no use

jpollard 10-15-2016 11:50 AM

Quote:

Originally Posted by P.G.Krish (Post 5618393)
No, I dont want to create trojan . Anyway how to change the access rules. I already change it permission. But no use

A simple chmod command will change the access. If you aren't allowed access because someone else owns the file, then you aren't allowed to edit the file. Copy it, edit the copy. BTW, changing the zip file belonging to someone else is considered making a trojan.

P.G.Krish 10-15-2016 11:55 AM

Quote:

Originally Posted by jpollard (Post 5618397)
A simple chmod command will change the access. If you aren't allowed access because someone else owns the file, then you aren't allowed to edit the file. Copy it, edit the copy.

But iam the owner of the file, i already try the chmod with 755 permissions ,

Thanks

grail 10-15-2016 12:10 PM

And when you entered that command were you given any errors? Maybe try adding -v to get more information.

I am also confused how the link you supplied has anything to do with your topic as nowhere does it mention a read only file, zip or otherwise.

P.G.Krish 10-15-2016 12:42 PM

Quote:

Originally Posted by grail (Post 5618407)
And when you entered that command were you given any errors? Maybe try adding -v to get more information.

I am also confused how the link you supplied has anything to do with your topic as nowhere does it mention a read only file, zip or otherwise.


Please read completely that third stage about editing the zip file, In that link

grail 10-15-2016 01:10 PM

I see all the stages and the steps you have followed, however, I repeat, nowhere in the entire page does it say the zip file is read only. It only says that you are editing the zip file.

jpollard 10-15-2016 03:21 PM

Just what does "ls -l" report about "your" file?

And if you are on a RH/Centos/Fedora release, what does "ls -lZ" report about the file?

P.G.Krish 10-17-2016 12:12 AM

Quote:

Originally Posted by jpollard (Post 5618473)
Just what does "ls -l" report about "your" file?

And if you are on a RH/Centos/Fedora release, what does "ls -lZ" report about the file?



This is result of
Code:

ls -l
Quote:

-rwxr-xr-x 1 krish krish 2472 Oct 17 10:38 cmd.zip

spiri13 10-17-2016 01:41 AM

Try to 'chattr -i file'.

P.G.Krish 10-17-2016 02:15 AM

Quote:

Originally Posted by spiri13 (Post 5618988)
Try to 'chattr -i file'.

Its not working with this file, spiri13

keefaz 10-17-2016 04:32 AM

Maybe vim opens the file as read only if a swap file is present and option v:swapchoice = "o" is set in vimrc
You can use ' :set noro ' to exit read only mode in vim


All times are GMT -5. The time now is 09:15 PM.