LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 02-24-2005, 10:34 PM   #1
fsbooks
Member
 
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 464

Rep: Reputation: 52
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.
 
Old 02-25-2005, 01:39 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 02-27-2005, 12:45 AM   #3
fsbooks
Member
 
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 464

Original Poster
Rep: Reputation: 52
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.
 
Old 02-27-2005, 02:32 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 04-07-2005, 01:11 AM   #5
fsbooks
Member
 
Registered: Jan 2002
Location: Missoula. Montana, USA
Distribution: Slackware (various)
Posts: 464

Original Poster
Rep: Reputation: 52
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 :-)
 
Old 04-07-2005, 03:13 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Still odd ... I do (and did back then) indeed use the
same thing :}


Cheers,
Tink
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scp does not work and gives the following error message: scp: FATAL: Executing ssh1 i akay Linux - Networking 16 09-28-2008 11:41 PM
FC 4. Modify ALT+TAB behaviour to CTRL+TAB xtracto Linux - Software 1 09-22-2005 02:06 PM
adding an option to a 'tab' completion + ls whatnoname Linux - Newbie 2 06-07-2005 07:32 AM
How can I turn on/install tab completion which I am so used to. jimdaworm *BSD 2 04-06-2005 11:25 PM
apt-get tab completion atheist Debian 6 06-11-2004 08:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:55 AM.

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