nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Shell script needed

This is a discussion on Shell script needed within the Shell scripting forums, part of the Development/Scripting category; Hello folks, I am a beginner and this is the first time I have started learning how to deal with ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 06-13-2008, 07:03 AM
Junior Member
User
 
Join Date: Jun 2008
My distro: Fedora
Posts: 1
Rep Power: 0
supamaka is on a distinguished road
Smile Shell script needed

Hello folks,

I am a beginner and this is the first time I have started learning how to deal with Unix based operating system and shell programming, I have a doubt as to how to write a pretty simple shell program, it is very simple for someone who knows shell programming and isn't that simple for the one who doesn't know much about it.

I hope some of the members here help me with either providing references or providing me hints as to how to write the code.

Here is the question:

Write a shell script (bash or sh) that prints out the following lines/information:
  1. Name: "Your name"
  2. Hostname: "The computer's hostname"
  3. Host IP: "The computer's IP number"
  4. Default Gateway: "The computer's default gateway"
  5. OS Version: "Whatever information on the OS version you can get programaticly"
  6. Memory: "The amount of physical memory (not disk) the system has"
  7. CPU Speed: "The CPU speed (in Hz not mip the system thinks it has"
  8. Disk space: "The amount of agregate physical disk the system has"
  9. A list of shells supported on the system for login (One per line)
  10. A blank line (or two)
  11. The shell script
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-13-2008, 10:26 PM
Junior Member
User
 
Join Date: Feb 2008
My distro: .
Posts: 10
Rep Power: 0
unSpawn is on a distinguished road
Default

FWIW, and this may not apply to you but, homework assignments usually aren't given to make you Bash your head against the wall so to speak but to practice things you learnt, so if this is one of those assignments you might want to read back what's been talked about. You could start by reading some tutorials and walkthroughs like BASH Programming - Introduction HOW-TO, http://www.tldp.org/LDP/Bash-Beginne...tml/index.html and the Linux Shell Scripting Tutorial - A Beginner's handbook. Once you've read that you could try looking at some scripts here: Bash Shell Scripting Directory For Linux / UNIX and see if you can understand what they're doing.
Reply With Quote
  #3 (permalink)  
Old 06-14-2008, 12:10 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,061
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

yup, follow all those guides provided by unSpawn.

There is a sample script below in form of functions:
BASH Shell script Common functions library, it includes lots of day-today-life subroutine
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #4 (permalink)  
Old 06-14-2008, 02:46 AM
Junior Member
User
 
Join Date: Feb 2008
My distro: .
Posts: 10
Rep Power: 0
unSpawn is on a distinguished road
Default

Nice examples. BTW, in getDiskDrives() it's missing the GNU/Linux part:
t=($(awk '/[hs]d[a-z]$/ {print $4}' /proc/partition)
c="${#t[@]}"
t="${t[*]}"
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
How to initialize HDD using Shell script? meimei Shell scripting 1 05-13-2008 06:21 PM
Run mv command from ftp shell script subin Shell scripting 6 05-02-2008 10:44 AM
shell script for ftp the file vishal_titre Shell scripting 3 12-10-2007 09:40 AM
writing a shell script to find out my shell name jaymob123 Shell scripting 1 10-08-2007 01:36 AM
require shell script puppen Shell scripting 4 04-12-2006 10:42 PM


All times are GMT +5.5. The time now is 03:33 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36