#!/bin/sh
if [ $# -lt 2 ] then echo "Usage $0 servername envtype" exit 1 fi
servername=$1
envtype=$2
srv=echo $servername | tr "a-z" "A-Z"
srvtype=echo $envtype | tr "a-z" "A-Z"
echo $srv
echo $srvtype
if [ "${srv}" <> "SCP" ]; then if [" ${srv}" <> "RENTD" ]; then echo "Invalid servername" exit 1; fi fi
I am getting this error when running the shell script
- [ 2 -lt 2 ]
- servername=scp
- envtype=prd
- echo scp
- tr a-z A-Z
- srv=SCP
- echo prd
- tr a-z A-Z
- srvtype=PRD
- echo SCP SCP
- echo PRD PRD
- [ SCP ]
- [ SCP ] /tmp/testupper.sh: 19: [ SCP: not found
Edityour question (from theShareEditFollowFlagset of links? In edit mode, highlight the code and click the{ }button to format it. (Really, all that does is put 4 spaces in front of each line of code, but that's all markdown needs.) See also stackoverflow.com/editing-help for other available formatting in questions and answers. And, even though you found your answer, it's still worth editing for posterity