Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-24-2005, 10:34 PM
|
#1
|
Member
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 464
Rep:
|
tab completion with scp
A person learns new things all the time. I was scp'ing a file to another machine, and happened to hit tab by habit while entering the pathname on the other machine, and lo and behold, it completed it. The path does not exist on the local machine. I found some reference to it in a post here but I had never heard of this. Does bash save the paths from machines? If so where (it was not in the history file). ...surely it does not make a connection to the other machine just for path completion. Just quite intrigued, any info is welcome.
|
|
|
02-25-2005, 01:39 AM
|
#2
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
I wouldn't have thought so, either... give's the example of
what it expanded? I had cases that an expansion gave me
a "path" on the remote machine when part of it matched ...
E.g. I was in ~, have a directory downloads ...
scp test.tar.gz tink@machine:/home/do<TAB> and it completed
the "wnloads" for me ... of course, the "full" path didn't exist on
the remote machine ...
Cheers,
Tink
|
|
|
02-27-2005, 12:45 AM
|
#3
|
Member
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 464
Original Poster
Rep:
|
It does make an ssh connection. I suspect it only works with the use of passwordless publickeys.
Here is a real example (except for hostname):
I have a /tmp/mp3 directory on both the host and the client, but they have totally different file structures. I know I have not accessed these on the host, but when I do the following scp /etc/hosts myhomecomputer.net:/tmp/add
Then hit tab (a few times, response is not immediate like on the local machine), I get the following:
$ scp /etc/hosts myhomecomputer.net:/tmp/mp3/add_200
/tmp/mp3/add_2004-03-21/ /tmp/mp3/add_2004-07-31/ /tmp/mp3/add_2004-12-10/
/tmp/mp3/add_2004-05-05/ /tmp/mp3/add_2004-11-07/ /tmp/mp3/add_2005-01-14/
/tmp/mp3/add_2004-06-23/ /tmp/mp3/add_2004-11-08/ /tmp/mp3/add_2005_01_08/
Those are the directories that begin with add. It adds the 200 and then gives the directories (there are three per line, wrapped in this window).
if I type "scp /etc/hosts myhomecomputer.net:/tmp/sa" and then hit tab, I get
$ scp /etc/hosts fsbooks.homeunix.org:/tmp/save
/tmp/save/ /tmp/save2/
I have a /tmp/save, a /tmp/sage, but no /tmp/save2 on the local computer.
Proof is in the log files. I use public keys, so everytime I get a little more information with the tab key (viewed with tail -f /var/log/messages in another terminal window), I get a line in the host /var/log/messages file (again computer name, login name, and IP obscured):
Feb 26 23:37:22 myhomecomputer sshd[9984]: Accepted publickey for fsbooks from ::ffff:000.000.00.0 port 52307 ssh2
Feb 26 23:37:33 myhomecomputer sshd[9992]: Accepted publickey for fsbooks from ::ffff:000.000.00.0 port 52325 ssh2
Kind of cool.
Last edited by fsbooks; 02-27-2005 at 12:46 AM.
|
|
|
02-27-2005, 02:32 PM
|
#4
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
How odd ... I can't replicate that behaviour, even though
I have passwordless ssh connections to two machines
set-up here ... bash-completion is on a pretty high level,
too, but only the original version of gnu.org ... maybe the
distro you're using has hacked that thing?
Cheers,
Tink
|
|
|
04-07-2005, 01:11 AM
|
#5
|
Member
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 464
Original Poster
Rep:
|
The package bash-completion-20040711-noarch-1 (which is installed on this slackware-current box) adds this capability. I came across the file /etc/bash_completion accidentally.
Quote:
# swaret --show bash-completion-20040711-noarch-1
Description for bash-completion-20040711-noarch-1:
----------------------------------------------------------------------
Adds programmable completion to the bash shell. A new file called
/etc/bash_completion will be sourced for interactive bash shells
adding all sorts of enhanced command completion features. Once
installed, you may get a list of all commands that have associated
completions with 'complete -p', and examine the code for the shell
functions with 'declare -f'.
bash-completion was written by Ian Macdonald <ian@caliban.org>.
----------------------------------------------------------------------
# complete -p|grep scp
complete -o nospace -F _scp scp
|
I kind of like it, particularly now that I know where it comes from :-)
|
|
|
04-07-2005, 03:13 PM
|
#6
|
Moderator
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
|
Still odd ... I do (and did back then) indeed use the
same thing :}
Cheers,
Tink
|
|
|
All times are GMT -5. The time now is 01:22 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|