org' and 'space' a specific route belongs to.1. 'cf login' to log in to each PCF foundation and 'cf t -o system -s system'
2. 'cf check-route <HOSTNAME> <DOMAIN>' to check if the specific route exists in the PCF foundation. The HOSTNAME and DOMAIN can be retrieved from the specific route and they are separated from each other by the first period ("dot"). For example:
ROUTE: spring-music-busy-buffalo.cfapps.pivotal.io HOSTNAME: spring-music-busy-buffalo DOMAIN: cfapps.pivotal.io COMMAND: cf check-route spring-music-busy-buffalo cfapps.pivotal.io
3. Save the shell script below as a file 'route_org_space.sh' and then run it with 'bash route_org_space.sh'. The small script will prompt you to input the HOSTNAME and then show you the org and space the specific route belongs to.
#!/bin/bash # prompt users to input the host name of a specific route echo "Hello, what's the host name you are looking for?" read HOSTNAME echo # get corresponding space info and store it into one temproray file cf curl `cf curl /v2/routes | grep -w $HOSTNAME -A 10 | grep '"space_url"' | cut -d'"' -f 4` > /tmp/space_info.out # display the org name echo "The org is: " cf curl `grep '"organization_url"' /tmp/space_info.out | cut -d'"' -f 4` | jq .entity.name # display the space name echo "The space is: " cat /tmp/space_info.out | jq .entity.name # clear the temporary file rm -rf /tmp/space_info.out