LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 07-07-2001, 08:00 PM   #1
nabil
Member
 
Registered: Feb 2001
Location: MI, USA
Distribution: Debian Linux 100% GNU
Posts: 210

Rep: Reputation: 31
Scripting


Hi all,

I am trying to make simple install script which consist of a bunch of cd.. make.. make install .configure and such also editing some Makefiles in the way. How can I do the editing part. I like to do it in VI as in VI a certain file to change stuff in it or even create new ones with stuff in them.Please remeber that this install script will have to be completley automatic with little manual intervention required if not possible.

Thanks for any help.
 
Old 07-07-2001, 09:07 PM   #2
nabil
Member
 
Registered: Feb 2001
Location: MI, USA
Distribution: Debian Linux 100% GNU
Posts: 210

Original Poster
Rep: Reputation: 31
Just to make the VI part more clear, I like to be able to go into certain files in VI and modify certain statemtens there to say whatever, also make new files in VI aslo to say what ever.
This need to be done on the fly using a pre-made script off course.

Thanks.
 
Old 07-07-2001, 09:29 PM   #3
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 121Reputation: 121
I'm still a bit unclear at what you are trying to do. Could you provide a small example of what type of editing and file creation you want to do with vi in your script.
 
Old 07-07-2001, 09:44 PM   #4
nabil
Member
 
Registered: Feb 2001
Location: MI, USA
Distribution: Debian Linux 100% GNU
Posts: 210

Original Poster
Rep: Reputation: 31
OK,
Let say I wanted to go from root directory / and create a file in VI called test in /var which will have a test line in it that say "This is a test then save that and go in to in other directory in /etc for example and edit an existing file called "defaults" and modify an entry on the forth line from yes to no.

The way I was thinking to do this is by creating an executable file to read:
"
vi /var/test
then something....something..
vi /etv/defaults
then something...somthing..

"

I hope this explained what I am trying to do.

Thanks for the inquiry...
 
Old 07-08-2001, 01:29 AM   #5
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
just offhand, if you're trying to edit makefiles or other textfiles on the fly, you should probably use sed, not vi.
 
Old 07-08-2001, 06:26 AM   #6
nabil
Member
 
Registered: Feb 2001
Location: MI, USA
Distribution: Debian Linux 100% GNU
Posts: 210

Original Poster
Rep: Reputation: 31
OK,
Can you post an example for using sed in this matter. I never used sed before.
Thanks.
 
Old 07-08-2001, 12:41 PM   #7
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 121Reputation: 121
Here is an example of what you described.

Code:
# Create a file in /var
cd /
echo "This is a test" > /var/test

# Edit defaults in /etc
cat /etc/defaults | sed '4s/yes/no/' > /etc/defaults
There are a ton of things you can do with sed. I'd suggest you find a good book on it. You should also take a look at awk. It is more difficult to learn than sed, but once you know it, awk can be quite powerfull.
 
Old 07-09-2001, 07:03 AM   #8
SensFan
Member
 
Registered: May 2001
Location: Toronto, Canada
Distribution: Slackware
Posts: 67

Rep: Reputation: 15
I'd agree with isajera sed would help you out. Here are some examples.

http://www.emunix.emich.edu/~khailan...d-examples.htm
 
Old 07-09-2001, 07:07 AM   #9
jharris
Senior Member
 
Registered: May 2001
Location: Bristol, UK
Distribution: Slackware, Fedora, RHES
Posts: 2,243

Rep: Reputation: 46
You might also want to look into the other tools that are often piped together to play about with text - awk, cut, tr, grep to name but a few little bits.

Jamie...
 
  


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
new to scripting mifan Linux - Newbie 2 08-17-2005 12:10 PM
another help with scripting?! ice99 Programming 2 08-09-2005 08:56 AM
Need help scripting Tamara Programming 7 06-06-2005 02:06 AM
Scripting Help Please Jazinator Linux - Newbie 7 10-17-2004 06:35 PM
scripting bforest Linux - Newbie 4 05-11-2004 02:45 AM

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

All times are GMT -5. The time now is 03:09 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration