need one help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need one help
# 1  
Old 03-27-2008
need one help

Hii,

I have a file that is read only file.i want to change the permission of the file remaining inside the file.How can i do that.

i used this

:! chmod 755 %

but it is not doing the desired thing.

Help me out in this.
# 2  
Old 03-27-2008
What does "remaining inside the file" mean?

What do :! and % signify above? If they are features of your shell then please mention which shell.

chmod 755 file will turn on read, write, and execute for the owner, and read and execute for others.
# 3  
Old 03-27-2008
I opened a file with vi say

vi filename

this file is read only that is i can not do any modifications in this.
i want to be inside vi and change the permission of the file.
is this helpfull.

Thanks.
# 4  
Old 03-27-2008
How can you edit a file that has read only priv ??

If you have the write priv then you can include the foll to change the
other privs

chmod 777 $0

and run the script again....note the permissions change thereafter...
# 5  
Old 03-27-2008
Please don't advise chmod 777 as it has rather undesirable security effects.

As a workaround you can write the file to /tmp from within your editor and then replace the file from the prompt after you have changed the permissions.
# 6  
Old 03-27-2008
Open the oldfile in the vi editor in Esc mode

use the following

:w newfilename

It will create a copy of the oldfile having write priv.....

Hpe this helps Smilie
# 7  
Old 03-28-2008
HI,
It works Perfectly for me!!!!!!!!!!!!!!!!!

I created a file called "test" and then i opened it using the command

"vi test"

and then u should save the file once and only then u can modify it by opening the file and giving the command :!chmod 777 %..

Regards,
aajan
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question