LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-02-2009, 01:05 AM   #1
smturner1
Member
 
Registered: Oct 2009
Location: MI
Distribution: Arch 2.6.35
Posts: 107

Rep: Reputation: 1
Talking E212 error


Hi, I am having a hard time writing a shell script to a text file in vi.

I open a file via:
vi WK3-IA

I write my script, and then switch to command :!wq [enter]

I get a E212 cannot write to file. Obviously I know that there is a permission issue here, but how can I change the permission of a file I cannot save to??? The next obvious question is how to change the permission to a file that cannot be save to?

I tried:
chmod 700 WK3-IA

and it says the stupid file does not exist, which seems pretty obvious since I cannot save to the file after I opened it. Did I miss something here? I realize I am a newbie to Linux, but the logic seems to be missing somewhere here.

I would appreciate any help from the Guru's

Blessings,
Shaun
 
Old 11-02-2009, 01:17 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

First thing that catches the attention
Quote:
I write my script, and then switch to command :!wq [enter]
it should be
Code:
:wq!
to write and quit vi.

Maybe that's causing the problem. Could you try that first?

Kind regards,

Eric
 
Old 11-02-2009, 01:24 AM   #3
smturner1
Member
 
Registered: Oct 2009
Location: MI
Distribution: Arch 2.6.35
Posts: 107

Original Poster
Rep: Reputation: 1
That was a typo. But I tried it to be sure and get the same E212 cannot open file for writing.

Thanks,
Shaun
 
Old 11-02-2009, 02:11 AM   #4
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
If you are trying to change the permissions on the file make sure you are in correct directory before you execute the chmod command. Else it will end up giving errors.
 
Old 11-02-2009, 03:44 AM   #5
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
From readin the thread I'd say its a permission problem on the directory your trying to write the file to. And if you can't write the file it just does not exists. So you can't change permission on it.
In this case write the file your lacking permissions on to /tmp and fix permission issues later. Or use the shell escape sequence to change permissions

Cheers zhjim
 
Old 11-02-2009, 07:52 AM   #6
smturner1
Member
 
Registered: Oct 2009
Location: MI
Distribution: Arch 2.6.35
Posts: 107

Original Poster
Rep: Reputation: 1
Exclamation

Ok, that worked. However, it does not answer the question on how to change permissions on a vi file.

this is what i did:
vi WK3-IA
script
:wq!
kicks out E212 error

I try to go back to parent directory and type:
chmod 700 WK3-IA
it says that the file does not exist.

Could anyone give me instructions on how to change permissions on an existing file, and a new file so that I can handle it in the future?

Blessings,
Shaun
 
Old 11-02-2009, 07:59 AM   #7
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
Can you list the contents of the directory and paste it here and make sure you are changing the permissions from inside the directory where the file is.
 
Old 11-02-2009, 08:37 AM   #8
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Quote:
Originally Posted by smturner1 View Post
Ok, that worked. However, it does not answer the question on how to change permissions on a vi file.
Just for the record: It doesn't matter what kind of file you want to change permission on. Files are files under linux. (symlinks are some kind of exepction with permission...)

Quote:
Originally Posted by smturner1 View Post
Could anyone give me instructions on how to change permissions on an existing file, and a new file so that I can handle it in the future?
Your doing the right thing to change the permission of an allready existing file but a new file first has to be created to have it permissions change.

Maybe take a look at the umask binary and thing about group and other permissions. That one looks nice for an overview http://www.zzee.com/solutions/linux-permissions.shtml

Just to quickly sum it up: If you can't write to a directory you can't create the file. so it does not matter what kind of permissions you want to set on a new file.

Like linuxlover.chaitanya said give us a directory listing with
Code:
cd /path/to/directory/you/want
ls -l
ls -ld
Cheers Zhjim
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
creata E212 prashantgarg7 Linux - Server 1 09-08-2009 12:40 PM
Sendmail: eocket wedge , 504 error , dsn error, mail relay connection error djcs Debian 0 03-03-2009 01:41 AM
PHP Error Parse error: parse error, unexpected $ in /home/content/S/k/i/SkinCare4U/h CowanServices Programming 2 12-09-2008 09:26 PM
Suse CUPS error: cups(File)DoRequest error:client-error-bad-request smdonelan Linux - Hardware 6 04-17-2007 07:46 PM
updating new installation of 9.3 ERROR...ERROR...ERROR Morbid SUSE / openSUSE 3 08-16-2005 12:22 AM


All times are GMT -5. The time now is 06:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration