The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
one question for bash shell script zx1106 Shell Programming and Scripting 9 03-10-2008 12:40 AM
Bash shell script outthere_3 UNIX for Dummies Questions & Answers 2 01-31-2008 08:13 PM
BASH Shell Script Help -HELP! flamethrower0 Shell Programming and Scripting 2 12-30-2006 01:26 AM
bash shell script and ms-dos space13 Shell Programming and Scripting 1 11-10-2006 07:06 PM
need help with bash shell script vmtailor UNIX for Dummies Questions & Answers 2 03-03-2005 04:30 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-02-2003
norsk hedensk norsk hedensk is offline Forum Advisor  
Registered User
  
 

Join Date: Jul 2002
Location: new york
Posts: 1,025
bash shell script

im trying to teach my self bash shell scripting. i want to include command line arguments in my script i am writing for practice. when i run my script it dosnt make a difference what arguments there are, it just out puts the error message as if there were none. here is the check_opts () function in my script, can someone tell me whats wrong here ?

Code:
check_ops () # lets see what happens ...
{
NO_ARGS=0
E_OPTERROR=65

if [ $# -eq "$NO_ARGS" ] # should check for no arguments
then
	echo "Usage: `basename $0` <OPTIONS> -s <HOSTNAME> "
	echo "Try './serverstatus -h' for more information."
	exit $E_OPTERROR
fi

while getopts ":invhs:" Option
do
	case $Option in
		i )
			interactivemode_func
		;;

		n )
			non_interactivemode_func
		;;

		v )
			version_func
		;;

		h )
			help_func
		;;

		s )
			echo "will take hostname" # dunno how to do this hold on
		;;

		* )
			echo "Unimplemented option chosen"
		;;
	esac
done

shift $(($OPTIND - 1))
}



this is called by a main () function that is ran before anything. thanks !


edit: for option -s i will be setting the hostname that will be portscanned. usage would look like this:

./serverstatus -s hostname

if that is the only option i will want it to default to non interactive mode. i can post more of my script if someone needs to see what i am doing. it is all very simple, i run nmap <hostname> and set the output to $a

right now that is the first thing that is done with my server address right in the script. then all i do is grep $a for corresponding ports and echo if that service is running or not.


Last edited by norsk hedensk; 08-02-2003 at 11:17 AM..
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 08:41 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0