LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-31-2008, 11:05 PM   #16
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380

Quote:
Originally Posted by Quakeboy02 View Post
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.
 
Old 10-31-2008, 11:11 PM   #17
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
Good idea, but I think I'd need:
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:$3 $4
fi
And that's just too confusing for me. (Hey, I'm old and slow, and I'd rather see what I'm doing than have it abstracted off like that.) What I did was put an alias in my .bashrc to ".smblookup.sh"; which is just the script you posted. If the host is offline it gives me an error and that's what I'm looking for, anyway. This is pretty cool.
 
Old 10-31-2008, 11:21 PM   #18
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Haha, word! I'd completely forgot about the directory paths!
 
Old 12-01-2008, 06:23 PM   #19
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Linux 11 (Bullseye)
Posts: 3,407

Original Poster
Rep: Reputation: 141Reputation: 141
Quote:
Originally Posted by win32sux View Post
Telling a DHCP server to always give you a certain client IP and/or hostname should be really easy (unless your ISP has restricted administration options on the device, or if it lacks them).
I should have spent more time researching this comment, win32sux. I finally found it:

In file /etc/dhcp3/dhclient.conf
Code:
change this line:
#send host-name "andare.fugue.com";

to this:
send host-name "hostname";
I did this on each machine, and, at least with this router, I have access by hostname.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to configur DNS & DHCP in real environment mail2azharuddin Red Hat 1 08-12-2008 10:01 AM
How to play a video file on a machine without a desktop environment? lumix Linux - Software 2 05-20-2008 04:28 PM
Dual Boot Machine Fedora 5 / WinXP, XP messes up the IP addressing hferretluv Linux - Newbie 11 06-12-2006 11:47 PM
Multiple DHCP environment MarvinChao Linux - Wireless Networking 1 03-14-2004 12:32 AM
Reinitialising environment variable without restart the machine yenonn Linux - Newbie 7 02-28-2003 11:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration