LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 10-29-2006, 10:51 PM   #1
madman100
Member
 
Registered: Jul 2006
Posts: 37

Rep: Reputation: 15
vi & script building


Hi can any one help me with the command to build a script in vi as i am new to this or help me to build a test script so i can understand how to build my own

Thanks
madman100
 
Old 10-29-2006, 11:09 PM   #2
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Rep: Reputation: 32
the Hello World script

save into a file and chmod the file to at least 700

Quote:
#!/bin/bash

echo "hello world"
exit $?
check this out: http://www.intuitive.com/wicked/wick...-library.shtml

Last edited by chakkerz; 10-29-2006 at 11:11 PM.
 
Old 10-29-2006, 11:14 PM   #3
PatrickNew
Senior Member
 
Registered: Jan 2006
Location: Charleston, SC, USA
Distribution: Debian, Gentoo, Ubuntu, RHEL
Posts: 1,148
Blog Entries: 1

Rep: Reputation: 48
Are you asking for help on how to write a bash script or how to use vi?

If you want to write a bash script just write a text file where each line is the command you want to run. You can add more advanced structures like "if" statements and such, and there is a tutorial at http://pegasus.rutgers.edu/~elflord/unix/bash-tute.html

if you don't like it, there are about a bazillion others, just google "bash script tutorial"

As for vi, if you've never used it before I would recommend a different text editor. (Yes, I do know that this invites flames.) Vi is a very powerful text editor. Thus, it comes with a steeper learning curve even though it is very efficient. A great text editor, but using it on your first bash script is a bit like using a ballistic missile on a soup cracker.

I might recommend nano, it has a very WYSIWYG interface and is well suited to small taks. If you aren't bound to the command line you can use any number of graphical text editors. If you are stuck on vi, just google "vi tutorial" and you're sure to come up with a good bit.
 
Old 10-30-2006, 12:12 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
FYI, you'll find vim (Vi Improved) a little easier to work with eg syntax highlighting etc.
You may find vi has been aliased to vim already....
 
Old 10-30-2006, 01:34 AM   #5
smaudlin
Member
 
Registered: Dec 2004
Location: Benicia, CA
Distribution: Fedora 6,5,4 Mandrake 10.1
Posts: 46

Rep: Reputation: 15
most importantly and shows above make sure the first line is #!/bin/bash for a bash script. #!/usr/bin/expect for expect script #!/usr/bin/python etc....for the language your using. For python scipts and such you can google "python example" or "python script" and there's a bunch to look at.
 
Old 10-30-2006, 07:33 AM   #6
madman100
Member
 
Registered: Jul 2006
Posts: 37

Original Poster
Rep: Reputation: 15
Thanks to every for the help and links i will give this a go on the week end when a have free time play around with it

Thanks
madman100
 
  


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
building a bash script from an install script paranoid times Programming 6 07-29-2006 04:24 AM
kernel & module building as root linuxhippy Slackware 10 07-04-2006 10:07 AM
Building a script to run after user login callingrohit Linux - General 4 04-26-2006 07:05 PM
Building new box w/ new CPU & old hard drive: Will this work? tsw Linux - Hardware 2 07-28-2004 03:08 PM
building l;inux from a script in windows bob_man_uk General 1 04-20-2004 06:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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