Strip a string in sh

I have a list of servers that I need my script to ping however this list also has the env they belong too such as SIT, PRD, warehouse and so on.
The break character for each section is :
A value in my list would look like this...

brutus.grhq.xxx.com:warehouse

Where brutus.grhq.gfs.com is the server that the following code needs to ping. I am trying to figure out how to say....

/lcl/tools/bin/sshPing.pl $remote_server > /dev/null

But drop the :warehouse part. So another words I am trying to figure out how to say sshPing.pl brutus.grhq.gfs.com and drop the :warehouse.
I thought you could do something like |cut -f 1 -d: however I do not see how I could use that in that line of code to break up the string.
Any ideas? Really lost on this one.Thanks.

use Parameter Expansion

echo "brutus.grhq.xxx.com:warehouse" | sed 's/:.*//'

Any examples of how I might do that?
I do not see much for examples on Google.

var='brutus.grhq.xxx.com:warehouse'
remoteserver=${var%:*}

Well the problem is I do not really need to echo it. I just need to use the string.

I tried....

/lcl/tools/bin/sshPing.pl $remote_server | sed 's/:.*//' > /dev/null

But that did not work.

---------- Post updated at 07:43 AM ---------- Previous update was at 07:40 AM ----------

Also tried...

/lcl/tools/bin/sshPing.pl ${remote_server%:*} > /dev/null

But I got... bad substitution

---------- Post updated at 07:47 AM ---------- Previous update was at 07:43 AM ----------

Also tried...

var=$remote_server
remote=${var%:*}
/lcl/tools/bin/sshPing.pl $remote > /dev/null

But I still get an error of bad sub.

---------- Post updated at 07:55 AM ---------- Previous update was at 07:47 AM ----------

Tried this as well....

/lcl/tools/bin/sshPing.pl $remote_server sed 's/:.*//' > /dev/null

Any ideas? Thanks

Suppose you have the list of remote servers in a file:

while read var
do
  remote=${var%:*}
  /lcl/tools/bin/sshPing.pl $remote > /dev/null
done < file

Hi, LRoberts:

What shell are you using that franklin52's parameter expansion did not work? I'm just curious.

Perharps the following command substitution is good enough:

/lcl/tools/bin/sshPing.pl "$(echo $remote_server | cut -d: -f1)" > /dev/null

Regards,
Alister

It just does not seem to work. It does not like my syntax.
This is how I am trying it...

#!/bin/sh
for remote_server in `ypcat osiunix_pods |cut -f 1-2 -d: | sort -t : -k 2`
do
remote=$(remote_server%:*)
/lcl/tools/bin/sshPing.pl $remote > /dev/null

Any ideas?

---------- Post updated at 08:20 AM ---------- Previous update was at 08:17 AM ----------

I tried....

 /lcl/tools/bin/sshPing.pl "$(echo $remote_server | cut -d: -f1)" > /dev/null

But no luck. using #!/bin/sh

change '#!/bin/sh' to '#!/bin/ksh'

Changed but still does not work... As you can see it still has the whole string...
Now checking for quality connection to: gulfweed.grhq.gfs.com:OES2 ...

Can you post the output of:

ypcat osiunix_pods

Here is a sample output of....

ypcat osiunix_pods |cut -f 1-2 -d: | sort -t : -k 2
greenchromis.grhq.XXX.com:production
guppy.grhq.XXX.com:production
horsehead.grhq.XXX.com:production
jaguar.grhq.XXX.com:production
justy.grhq.XXX.com:production
kraken.grhq.XXX.com:production
leatherback.grhq.XXX.com:production
leviathan.grhq.XXX.com:production
lionhead.grhq.XXX.com:production
mahimahi.grhq.XXX.com:production
mangrove.XXX.com:production
marlin.XXX.com:production
marsh.grhq.XXX.com:production
mg.grhq.XXX.com:production
moccasin.XXX.com:production
molly.grhq.XXX.com:production
moray.grhq.XXX.com:production
odyssey.grhq.XXX.com:production
oscar.grhq.XXX.com:production
penguinshrimp.grhq.XXX.com:production
penribbon.XXX.com:production
rainbowfish.grhq.XXX.com:production
redclawedcrab.grhq.XXX.com:production
ringneck.XXX.com:production
roughgreen.XXX.com:production
sailfish.grhq.XXX.com:production
salmon.can.XXX.com:production
samurai.grhq.XXX.com:production
sandcrab.grhq.XXX.com:production
seaclam.grhq.XXX.com:production
sephia.grhq.XXX.com:production
skimmerclam.grhq.XXX.com:production
snakehead.grhq.XXX.com:production
spikystonecrab.grhq.XXX.com:production
spinychromis.grhq.XXX.com:production
spoonworm.can.XXX.com:production
starfire.grhq.XXX.com:production
steelhead.grhq.XXX.com:production
swordtail.grhq.XXX.com:production
tacoma.grhq.XXX.com:production
tahoe.grhq.XXX.com:production
torino.grhq.XXX.com:production
triggerfish.grhq.XXX.com:production
trumpetsnail.XXX.com:production
unicornfish.XXX.com:production
velvetfish.XXX.com:production
vendace.XXX.com:production
wahoo.grhq.XXX.com:production
walleye.grhq.XXX.com:production
walu.grhq.XXX.com:production
warbonnet.grhq.XXX.com:production
warmouth.grhq.XXX.com:production
wedgeclam.grhq.XXX.com:production
weedfish.grhq.XXX.com:production
weeverfish.grhq.XXX.com:production
yogi.grhq.XXX.com:production
adonistetra.grhq.XXX.com:sit
alewife.grhq.XXX.com:sit
anchovy.grhq.XXX.com:sit
anomura.grhq.XXX.com:sit
arkclam.grhq.XXX.com:sit
asianclam.grhq.XXX.com:sit
awningclam.grhq.XXX.com:sit
badis.grhq.XXX.com:sit
barclam.grhq.XXX.com:sit
barramundi.grhq.XXX.com:sit
beluga.grhq.XXX.com:sit

Try this:

ypcat osiunix_pods | sort -t : -k 2 | 
while IFS=":" read var dummy
do
  remote=${var%:*}
  /lcl/tools/bin/sshPing.pl $remote > /dev/null
done