print -n "\nEnter the client ID : "
read clientID
print $clientID

data=$(grep jms/erms/$clientID /export/home/a0706838/test.txt;)

print "\n $data"
getClientID=$(echo "$data" | awk '{print $8}'| perl -lne 'print substr($_,0,5)';)
print "$getClientID"
getClientID1=$(echo "$data" | awk '{print $9}'| perl -lne 'print substr($_,19,5)';)
getClientID2=$(echo "$data" | awk '{print $15}'| perl -lne 'print substr($_,20,5)';)

if [ -z "$data" ]
  print "Setup is not present on $i for $clientID"
  print "Please login to server $i manually and check for the client $clientID on path /apps/WebSphere/NA70_TBA/config/cells/CellV70_TBA/ in resources.xml file"
  print "==============================================================================================================================================================="

elif [ -z "$getClientID" ] | [ -z "$getClientID1" ] | [ -z "$getClientID2" ]
  print "Setup for client $clientID has been not done correctly on server $i. Please contact WasTech team for this."
  print "==============================================================================================================="

  print "\n"
  print "Setup is valid on $i for $clientID for CellV70_TBA path"
  print "====================================================================================================="

test.txt file

<factories xmi:type="resources.jms.mqseries:MQQueue" xmi:id="MQQueue_1549053088921" name="ERMS Message Queue - 16661" jndiName="jms/erms/16662" persistence="QUEUE_DEFINED" priority="QUEUE_DEFINED" specifiedPriority="0" expiry="UNLIMITED" specifiedExpiry="0" baseQueueName="TBAT.16662.SPM.ERMSIN" CCSID="1208" useNativeEncoding="true" integerEncoding="Normal" decimalEncoding="Normal" floatingPointEncoding="IEEENormal" targetClient="MQ" queueManagerPort="1414" sendAsync="QUEUE_DEFINED" readAhead="QUEUE_DEFINED">

1 Answer 1


A logical "or" is written || in the shell. A pipeline (|) is something else. In particular the exit status of a pipeline is that of the last command, so only the last condition would apply here.

[ -z "$getClientID" ] | [ -z "$getClientID1" ] | [ -z "$getClientID2" ]

should be

[ -z "$getClientID" ] || [ -z "$getClientID1" ] || [ -z "$getClientID2" ]

Your parsing of the given XML is also questionable and fragile, but I can't really say much about it since you don't tell us what it is you're parsing out of this file (and it's not the main point of the question). It would probably break if the name attribute's value changed in such a way that more words were added, or some words were removed. It also depends on the ordering of the attributes. The ordering is semantically not important to the XML format, and neither is the amount or type of whitespace between the attributes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .