LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 11-25-2009, 11:57 AM   #1
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Rep: Reputation: 47
Bash hostname completion not working.


According to the Bash man pages,

Quote:
HOSTFILE
Contains the name of a file in the same format as /etc/hosts that should be read when the shell needs to complete a hostname. The list of possible hostname completions may be changed while the shell is running; the next time hostname completion is attempted after the value is changed, bash adds the contents of the new file to the existing list. If HOSTFILE is set, but has no value, bash attempts to read /etc/hosts to obtain the list of possible hostname completions. When HOSTFILE is unset, the hostname list is cleared.
Here's the line in my .bashrc where HOSTFILE is set:

Code:
export HOSTFILE="~/.hosts"
I opened a new bash session, created ~/.hosts, filled it with the names of servers that I wanted to expand using tab completion. then typed

Code:
ssh p<tab><tab>
expecting to get a lists of all of the hosts in ~/.hosts starting with 'p'. Bash simply beeped at me twice.

I tried
Code:
$ shopt hostcomplete
hostcomplete    on
Code:
 ssh bchittenden@p<tab><tab>
same results.

Code:
 > bash --version
GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
Has anyone successfully set up hostname completion? What am I missing?

Last edited by bartonski; 11-25-2009 at 12:00 PM.
 
Old 11-25-2009, 02:06 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

Change this: export HOSTFILE="~/.hosts"
to this: export HOSTFILE="/home/username/.hosts"

It doesn't seem to work with the ~, it needs the full path to the hosts file.

Hope this helps.
 
1 members found this post helpful.
Old 11-25-2009, 03:35 PM   #3
bartonski
Member
 
Registered: Jul 2006
Location: Louisville, KY
Distribution: Fedora 12, Slackware, Debian, Ubuntu Karmic, FreeBSD 7.1
Posts: 443
Blog Entries: 1

Original Poster
Rep: Reputation: 47
Quote:
Originally Posted by druuna View Post
Hi,

Change this: export HOSTFILE="~/.hosts"
to this: export HOSTFILE="/home/username/.hosts"

It doesn't seem to work with the ~, it needs the full path to the hosts file.

Hope this helps.
Yep, that worked.

$HOME/.hosts works as well; I prefer this because I can move my .bashrc between accounts with different $HOME directories.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Still getting to know Bash, question about tab-completion kaldrenon Linux - Newbie 5 12-19-2008 08:51 AM
bash completion "complete -f" not working iamback Linux - Software 1 05-21-2008 11:43 PM
Bash auto-completion question PatrickNew Linux - General 3 05-02-2008 11:31 PM
xterm and bash completion athanatos Slackware 12 07-22-2006 12:47 PM
question about bash completion Guest1234 Linux - Software 4 02-25-2006 04:09 PM


All times are GMT -5. The time now is 04:34 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration