The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 05-27-2009
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
  
 

Join Date: Nov 2006
Location: Bulgaria
Posts: 1,322
Another simple example in bash (if you do not care about the switches' names) :
Code:
#!/bin/bash

parseArguments() {
    if [[ $# -lt 3 ]]; then
        echo "Usage: $0 host user pass"
        exit 1
    fi
host="$1"
user="$2"
pass="$3"

# do you stuff here, and put the following at the main part of the script : 
parseArguments() $@
The $0 is the name of the script.