I am trying to set up prompts when you don't enter the right information or dont enter the information at all, when executing a script. Below is the question that i am asking and i am not sure how to set up the if statements to make sure that the user enters the name, cpu's, memory and ip. I was told that getopts with a cease statement might be usefull, but im not sure how to apply it. Any help would be greatly appreciated...
hey
need help with getopts again.
i am using getopts to read my command line options and arguments. i can manage to do for options that have only one argument
e.g srcipt_name -f 3
i am able to use getopts to do this but i am having problems two accept more than two agruments
e.g.... (1 Reply)
hello there I am back with more questions (sorry it is been quite a while since I had done scripting). I had tried the search function to search for the threads that might have an answer to my question, but I could not find it, so I had decided to post it.
I had created the scripts below in ksh... (2 Replies)
is there a better way to check if all args are set???
while getopts h:p:u: opt
do
case "$opt" in
h) host="$OPTARG";;
p) port="$OPTARG";;
u) user="$OPTARG";;
\?)
echo >&2 \
"usage: $0 -h host -p port -u user"
exit 1;;
esac
done
... (1 Reply)
Hi
i have part of the scripts below ,getopt for -h or ? not working for me.
can anybody tell me if this sytax right or wrong.
#!/usr/bin/ksh
program=$(basename $0)
#####################################################################################
function usageerr
{
RC=1
... (3 Replies)
could anyone please tell me what this will automatically set my variable all=True....
#!/bin/sh
all=FALSE
while getopts a: option
do
case "option"
in
a) all=TRUE;;
/?) echo "...... "
exit 1;;
esac
done
if
then
echo "true"
else
echo "false" (2 Replies)
I am trying to use the finction getopts in script.
From what I understand this can be an example for using:
while getopt "p:rvt:"
do
case
p)
echo "$OPTARG"
;;
r)
echo... (5 Replies)
Suppose I have a code below .
while getopts a: opt
do
case $opt in
a) app_name="$OPTARG";;
*) echo "$opt is an invalid option";
exit 1;;
?) echo "The value of $OPTARG is an invalid option";
exit 1;;
esac
done
Could anyone please tell me in which case my... (1 Reply)
Hi All,
I am writing a script to pass the getopts argument to the function which I have. But it as soon as I execute the script, the argument is taking it as blank. I tried using multiple way to check but its not working.
Can someone please let me know what wrong in this code.
function1()... (4 Replies)
Hi. Can somebody please show me an example of how to use getopts to assign a variable if it's been passed into the script but to set a default if no value has been passed in? And also how to handle a param with multiple values ... so a sub parse (can I use a function for this?)?
Here's my code... (1 Reply)
There are many places where I can see the syntax description for optargs, which, usually boils down to this:
getopts OPTSTRING VARNAME
where:
OPTSTRING tells getopts which options to expect and where to expect arguments
VARNAME tells getopts which shell-variable to use for option reporting... (2 Replies)
Discussion started by: sharkura
2 Replies
LEARN ABOUT DEBIAN
printna
MESSAGES(3) libbash messages Library Manual MESSAGES(3)NAME
messages -- libbash library that implements a set of functions to print standard status messages
SYNOPSIS
printOK [indent]
printFAIL [indent]
printNA [indent]
printATTN [indent]
printWAIT [indent]
DESCRIPTION
General
messages is a collection of functions to print standard status messages - those [ OK ] and [FAIL] messages you see during Linux boot process.
The function list:
printOK Prints a standard [ OK ] message (green)
printFAIL Prints a standard [FAIL] message (red)
printNA Prints a standard [ N/A] message (yellow)
printATTN Prints a standard [ATTN] message (yellow)
printWAIT Prints a standard [WAIT] message (yellow)
Detailed interface description follows.
indent
Column to move to before printing.
Default indent is calculated as TTY_WIDTH-10. If current tty width can not be determined (for example, in case of serial console), it
defaults to 80, so default indent is 80-10=10
FUNCTIONS DESCRIPTIONS
printOK [indent]
Prints a standard [ OK ] message (green)
printFAIL [indent]
Prints a standard [FAIL] message (red)
printNA [indent]
Prints a standard [ N/A] message (yellow)
printATTN [indent]
Prints a standard [ATTN] message (yellow)
printWAIT [indent]
Prints a standard [WAIT] message (yellow)
EXAMPLES
Run a program named MyProg, and report it's success or failure:
echo -n 'Running MyProg...'
printWAIT
if MyProg ; then
printOK
else
printFAIL
fi
AUTHORS
Hai Zaar <haizaar@haizaar.com>
Gil Ran <gil@ran4.net>
SEE ALSO ldbash(1), libbash(1)Linux Epoch Linux