LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-19-2009, 12:27 AM   #1
saghi
LQ Newbie
 
Registered: Sep 2008
Posts: 28

Rep: Reputation: 15
Question sed command error


hi,
I have a problem with sed command.I write a script that contain:
export BR_CODE=`echo $HOSTNAME|rev|cut -c 1-2 |rev`
sed -i 's/@BR_CODE@/'$BR_CODE'/g' /home/admin/rman/live/rmanfullstdby.rcv

and after run the script I faced to below error:
sed: couldn't open temporary file /home/admin/rman/live//sedYU2J6x: Permission denied

the rmanfullstdby.rcv file is 777 and the owner is root:dba.I run the script by oracle user.
but when I run this script by root user ,It executed without error.
could anyone help me?
 
Old 04-19-2009, 12:55 AM   #2
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
What are the permissions on the folder?

The issue seems to be that the oracle user cannot create the temporary file that it needs.

Any reason the folder could not be owned by oracle?
 
Old 04-19-2009, 01:03 AM   #3
saghi
LQ Newbie
 
Registered: Sep 2008
Posts: 28

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Disillusionist View Post
What are the permissions on the folder?

The issue seems to be that the oracle user cannot create the temporary file that it needs.

Any reason the folder could not be owned by oracle?
the subfollder can not owned by root:admin.
 
Old 04-19-2009, 01:05 AM   #4
saghi
LQ Newbie
 
Registered: Sep 2008
Posts: 28

Original Poster
Rep: Reputation: 15
the subfolder is owned by root:admin.and this is the problem.
 
Old 04-19-2009, 01:31 AM   #5
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
Quote:
Originally Posted by saghi View Post
the subfolder is owned by root:admin.and this is the problem.
Exactly.

What I wanted to know is, do you have any issues with changing the folder permissions to oracle:dba

As root:
Code:
chown oracle:dba /home/admin/rman/live
 
Old 04-19-2009, 02:55 AM   #6
saghi
LQ Newbie
 
Registered: Sep 2008
Posts: 28

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Disillusionist View Post
Exactly.

What I wanted to know is, do you have any issues with changing the folder permissions to oracle:dba

As root:
Code:
chown oracle:dba /home/admin/rman/live
even I change /home/admin/rman/live to root:dba ,the error occure again. and I can not change /home/admin to roor:dba.it must be root:admin.
 
Old 04-19-2009, 03:27 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
If you don't have write access for the directory, then you can't create files in it. You might try using ed instead of sed. Then you might be editing the file instead of using a temporary file. In this test, I removed write access to the testdir/ directory. I used ed to delete a line. The ed program is contained in a HERE document.

Code:
jschiwal@qosmio:~> ls -l testdir
total 8                         
-rwxrwx---+ 1 jschiwal jschiwal 2672 Apr 19 03:16 directory
-rw-rw----+ 1 root     root     2738 Apr 19 03:07 directory2
jschiwal@qosmio:~> ls -ld testdir
dr-xr-x---+ 2 jschiwal jschiwal 4096 Apr 19 03:07 testdir
jschiwal@qosmio:~> tail -4 testdir/directory
wordlist
work
workplace.mov
yofra.zip
jschiwal@qosmio:~> ed testdir/directory <<EOE
> /wordlist/
> d
> w
> q
> EOE
2672
wordlist
2663
jschiwal@qosmio:~> tail -4 testdir/directory
video-1.flv
work
workplace.mov
yofra.zip
A here document can contain bash variables which are evaluated. See the info bash manual (section 3.6.5) for more info.

You haven't posted the full permissions of the /home/admin/rman/live/ directory. I don't know if the user executing the command has r-x access to the directory.

If you want the last two characters of the HOSTNAME for the BR_CODE, you could use BR_CODE=${HOSTNAME:${#HOSTNAME}-2}

Note: I ran the here document example interactively, hence the > characters.

---

Another option is to use an acl to allow the `admin' user write access to the directory.
setfacl -m user:admin:rwx /home/admin/rman/live/

Last edited by jschiwal; 04-19-2009 at 04:40 AM. Reason: Added setfacl info.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sed command error - what am i doing wrong? Morrighan Linux - Newbie 8 06-15-2008 11:12 AM
'sed: command garbled:' error on Solaris fatjack Solaris / OpenSolaris 3 08-25-2006 05:15 PM
sed error message:extra characters after the command wmh830621 Programming 4 08-14-2006 07:13 PM
sed command help... Pete.Hanson@jacobs.c Programming 8 06-02-2006 05:53 PM
sed error message: extra characters after the command. nano_mag Linux - General 3 05-15-2005 01:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:03 PM.

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
Open Source Consulting | Domain Registration