Quote:
Originally Posted by Quakeboy02
Sweet! I'll have to figure out whether I need to do something different for hosts that aren't there or are typed wrong. But, it gives "name_query" in those cases, so that'll probably work well enough.
Thanks again!
Added:
Yes it works.
|
I'm glad it works. Here's an example of how you might deal with the offline hosts and errors:
Code:
#!/bin/sh
USER_NAME=$2
IP=`nmblookup -B -L $1 | tail -n 1 | awk '{print $1}'`
if echo $IP | grep name_query > /dev/null ; then
echo "ERROR: Couldn't find an IP for that host. Are you sure it is online?"
else
rsync -av $USER_NAME@$IP:/fromhere /tothere
fi
This script basically takes two arguments when you call it. The first one is the hostname you want to find the IP for, and the second is the user name you want to use in the
rsync command. If the output of the awk on the lookup is "name_query" it will throw an error, otherwise it will do the
rsync using the IP which was found and the username you provided.