[Cialug] scp w/full path
Daniel A. Ramaley
daniel.ramaley at drake.edu
Mon Mar 3 10:47:26 CST 2014
Create a script called "lazy" with these contents:
#!/bin/sh
scp "${1}" "${2}:${PWD}/"
Please note that i did not test it, so it may not be perfect.
Run "lazy file1 host" and it should do what you want. Configure the host
in your ~/.ssh/config to already know the username (if it is not the
same as your local user name) so you don't have to specify that. And in
case you *do* have to specify it, using the user at host syntax to the
script should still work.
If the host is always the same, change "${2}" to the name of the host
for even more laziness.
For further laziness, name the script a single letter that is not used
by any other programs. On my system, "l" is not in my path, so i could
name it that and then just have to type "l file1" to have it work. Is
that lazy enough?
I rarely have to copy files amongst systems such that the paths are
identical on both source and destination, so a script like this would be
of limited utility for me. If you need a bit more power, set up SSH keys
between your systems (so you don't need a password to authenticate), and
then set up bash completion. (On many distros there is a package named
"bash*completion" for some value of "*".) With bash completion, you can
just hit the tab key a couple times and it'll print out the path options
on the remote system, just like bash natively does for the local
filesystem. Of course, if you don't use bash then you'll have to find a
similar command completion configuration.
On 2014-03-03 at 10:27:24 L. V. Lammert wrote:
> On Mon, 3 Mar 2014, Barry Von Ahsen wrote:
> > I don't think he wants to type the path on both sides
> >
> > my lazy solution usually is:
> >
> > cd /to/the/path
> > pwd (copy output)
> > scp user at host:<paste> .
>
> Actually, that's WAY more than 'lazy' - guess we have different
> difinitions <g>!
>
> Seriously, the more I think about it, it may just be using $PWD but I
> have not had time to play with it - billing has priority today.
>
> Lee
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
__
Daniel A. Ramaley
Network Engineer 2
Dial Center 122, Drake University
2407 Carpenter Ave / Des Moines IA 50311 USA
Tel: +1 515 271-4540
Fax: +1 515 271-1938
E-mail: daniel.ramaley at drake.edu
More information about the Cialug
mailing list