LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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-21-2005, 08:57 PM   #1
davidbix
LQ Newbie
 
Registered: Aug 2005
Posts: 9

Rep: Reputation: 0
Newbie guide to scripts?


Someone posted this on the Knoppmyth forums, so I'm curious if anyone has an good newbie guide for getting started w/ scripts?

Thanks.

Code:
#!/bin/sh
# Written by Girkers
# with help from mjl
# and tjc

#Default Variables
sys="";
quest="Do you want to enable ";
ans="? [yn]:";
choice="";

#Remove the ntpd from running
update-rc.d ntpd remove

#Set the computer to keep time via a time server
#Daily and on a boot
 echo
 sys="KnoppMyth box to update it's clock via the Net";
 read -n1 -p "$quest$sys$ans" choice
 choice=$(echo $choice | tr "[a-z]" "[A-Z]")
 echo
 if [[ ${choice} = "Y" ]]; then
   region=""
   echo
   echo "Pick your time zone area via the corrosponding number:"
   echo "1 - Asia"
   echo "2 - Europe"
   echo "3 - North America"
   echo "4 - Oceania"
   echo "5 - South America"
   zone=""
   while [ -z "$zone" ] ; do
       read -n1 -p "Which region are you in:" region
       case "$region" in
         1) zone=asia ;;
         2) zone=europe ;;
         3) zone=north-america ;;
         4) zone=oceania ;;
         5) zone=south-america ;;
         *) echo "You must enter a number between 1 - 5";;
       esac
   done
   echo
   echo "Please wait applying your settings..."

   # Set the time to update from the net
   for FILE in /etc/cron.daily/mythtv-backend /etc/init.d/bootmisc.sh ; do
      [ -f "$FILE" ] && cp "$FILE" "$FILE.old" &&
      sed -e "/ntpdate/d" <$FILE >$FILE.new
      echo "/sbin/ntpdate $zone.pool.ntp.org &" >>"$FILE.new" &&
      mv "$FILE.new" "$FILE"
   done
   echo
   echo $sys "command complete"
 else
  echo $sys "skipped"
 fi
 
Old 10-21-2005, 10:02 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Jessie 8.4
Posts: 5,873

Rep: Reputation: 348Reputation: 348Reputation: 348Reputation: 348
Google up copies of:
Advanced Bash-scripting Guide
Bash Guide for Beginners
Bash Reference Manual
 
Old 10-21-2005, 11:57 PM   #3
shengchieh
Member
 
Registered: Jul 2004
Location: Palo Alto, CA
Distribution: #! Korora
Posts: 472

Rep: Reputation: 30
A list is at

http://www.websamba.com/Linux_Docs_Links
-> console commands
-> intro... & references

Also useful is
-> documentations
-> intro.. & general

Sheng-Chieh
 
Old 10-22-2005, 10:00 AM   #4
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
I found the best way to start with scripts was to read existing scripts and understand each line. Then make a few simple changes and see what happens. It took me years before I could start with an empty file (even if the file I started from required every line to be replaced!).
 
  


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
newbie need guide from forum yukistvn Linux - Newbie 1 04-29-2005 05:39 PM
Fun newbie guide. tripmix General 2 01-30-2005 11:45 AM
Newbie LAN guide Blueshark Linux - Networking 2 07-07-2004 06:58 AM
UnSpawn's Newbie Guide Obie Linux - Security 2 05-15-2004 02:31 AM
apache newbie guide Lleb_KCir Linux - General 5 03-27-2004 12:43 PM


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