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/