if [ $1 -eq "0" && $2 -eq "0" ]
then
echo " The request is authenticated "
fi
The error im getting is
$ ./routing.sh server enables
**********************************************************************
Preparing to service the request for Device server in Question
**********************************************************************
./routing.sh: line 46: [: missing `]'
USAGE
routing.sh <server> <disable|enable>
oops !! its my bad . The condition is when both the variable $1 $2 exit code is 0 it should display {Request Authenticated }. Since the above syntax is erroring out again
./routing.sh server123 enables
**********************************************************************
Preparing to service the request for Device Server123 in Question
**********************************************************************
./routing.sh: line 46: [: server123: integer expression expected
USAGE
routing.sh <device> <disable|enable>
This is the variable condition, on which im verifying.
enable = exit code 0
enables = exit code 1
server123= exit code 0 [ Existing Server]
serverABC= exit code 1 [ Non Existing Server ]
Condition 1. Device name doesn't exist in hosts file . The corresponding output can been seen here. Conclusion : Satisfied. Displays desired output.
But should have excluded " Correct Input Parameters "
$ ./routing.sh server123 enable
**********************************************************************
Preparing to service the request for Device server123 in Question
**********************************************************************
Correct Input Parameters
Invalid Server Request
Condition 2 : Incorrect state parameter . The corresponding output can be seen here. Conclusion : Very Much Satisfied. Displaying the USAGE.
$ ./routing.sh Server24-ra enables
**********************************************************************
Preparing to service the request for Device Server24-ra in Question
**********************************************************************
Correct Input Parameters
USAGE
routing.sh <device> <disable|enable>
Condition 3 When both parameters are correct, still this " Correct Input Parameters " is being displayed , either it should have omitted when both variables are satisfying the condition on which they are assigned too.
Conclusion: Not Satisfied. Need to work on it.
$ ./routing.sh server24 enable
**********************************************************************
Preparing to service the request for Device server24 in Question
**********************************************************************
Correct Input Parameters
Enabling the Device in few seconds
Report Logging . .
Thu Feb 11 13:18:00 CST 2010
FILE CREATED: outFile100211-131800.server24.enable
Global configuration mode
admin enabled
Configuration saved successfully.
Goodbye
*********************************************************************
But from above if loop changes its not being fully effective on the script, do we need to apply an elif statement here.
Maybe I am missing this completely, and that is possible, but what exactly are $1 and $2 resulting as? Are you certain they out what you think they are?
I have changed the script parameter & echoing statments. But u can be my help to resolve the new issue that occured after change.
Here is the head of the main script.
# Functional Usage
usage() {
echo
echo "USAGE"
echo " "`basename $0`" <device> <disable|enable> "
echo
exit 1
}
echo
echo "**********************************************************************"
echo " Preparing to service the request for Device ${1} in Question "
echo "**********************************************************************"
echo
if [ "$2" != 0 ]|| [ "$1" != 0 ]; then
echo " Check USAGE for correct Parameters "
fi
$0 = basename
$1 = device name
$2 = state operation (enable or disable)
Desired output on Condition 1 [ where server does not exist in host file & other parameter is not matching with the case ]
server123 = doesnt exist
enables= is wrong parameter. It should be " enable"
my desired output should be like this when both parameters are invalid .
$ ./routing.sh server123 enables
**********************************************************************
Preparing to service the request for Device server123 in Question
**********************************************************************
Check USAGE for correct Parameters
{ Not displaying the USAGE to the user }
Invalid Server Request
Should display the USAGE to the user as just given below:
Check USAGE for correct Parameters
USAGE
DPoutrotate.sh <device> <disable|enable>
Here is the second condition where i will like to see the change. Here one parameter is invalid & other is valid.
server123 = Inavlid
enable = valid.
$ ./DPoutrotate.sh server123 enable
**********************************************************************
Preparing to service the request for Device server123 in Question
**********************************************************************
Check USAGE for correct Parameters : Should be omitted from output.
Invalid Server Request