LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-27-2012, 09:23 AM   #1
bkone
Member
 
Registered: Jun 2006
Distribution: SUSE, Red Hat, Oracle Linux, CentOS
Posts: 108

Rep: Reputation: 15
Add lines end of file above the end comments


I have been beating my head on the table for almost 2 days now Googling and trying to figure out how to do this. It sounds easy enough I just am not going about it the right way obviously.

I am trying to create a script that will send an updated tnsnames.ora file down to a few of my Linux servers, running SLES, that will also update the Oracle tnsnames environment variable. It is basic but I can't figure out how to add this value:
Code:
TNS_ADMIN=/opt/tnsnames
export TNS_ADMIN
at the end of the /etc/profile but above the lines:
Code:
#
# End of /etc/profile
#
So in short I am trying to get the end of my /etc/profile file to look like this:
Code:
TNS_ADMIN=/opt/tnsnames
export TNS_ADMIN
#
# End of /etc/profile
#
Here is what I have minus the placement part in which I am trying to get figured out.
Code:
#!/bin/sh
mkdir /opt/tnsnames
cd /opt/tnsnames
wget http://webserver/tnsnames.ora
echo "TNS_NAMES=/opt/tnsnames" >> /etc/profile
echo "export TNS_NAMES" >> /etc/profile
Any help on this would be greatly appreciated. I have been trying to find the line # End of /etc/profile and then 2 lines up add the 2 lines noted above. Not sure if there is an easy way or more efficient but I am unable to figure it out.
 
Old 02-27-2012, 09:48 AM   #2
PenGUiN_6_1
Member
 
Registered: Oct 2006
Location: Brunswick, MD
Distribution: gNewSense 2.3 (deltah) i386
Posts: 57

Rep: Reputation: 22
Code:
#!/bin/bash
TNS_ADMIN=/opt/tnsnames
export TNS_ADMIN
Put this in /etc/profile.d/tnsadmin.sh (name it whatever you like, but put it in /etc/profile.d/;it will cycle through the .sh files there), then test it out in your system by echoing your variable. I hope this helps
 
Old 02-27-2012, 09:58 AM   #3
bkone
Member
 
Registered: Jun 2006
Distribution: SUSE, Red Hat, Oracle Linux, CentOS
Posts: 108

Original Poster
Rep: Reputation: 15
Thanks PenGUiN_6_1! That is brillant and so much simpler than what I was thinking. Thank you! Thank you!
 
  


Reply



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
[SOLVED] add a word in end of lines & edit with +1 in every line 1Volt Linux - Newbie 12 11-11-2011 03:03 PM
Running a Crafted bash script yelds 'Unexpected end of file' at the end of the file MCLover1337 Linux - General 5 10-15-2011 08:29 AM
[SOLVED] Using Vim to add something to the end of a series of a lines Vim-Newbie Linux - Newbie 3 05-23-2011 02:47 PM
Add comma to end of lines in text file Johng Programming 9 08-21-2010 04:15 AM
gui read out of back end command lines from gui front end activation? how? Siljrath Linux - General 0 10-24-2008 10:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:46 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