How to ssh copy a file from local to web host when logged in?
Matt Graham
danceswithcrows at usa.net
Mon Dec 20 09:07:35 MST 2010
From: Alex Dean <alex at crackpot.org>
> On Dec 19, 2010, at 3:31 PM, joe at actionline.com wrote:
>> But my question was what syntax should I use *while I am logged in*
>> to my web host server to copy a file (or directory) from my local
>> system to my web host server.
>> # scp [what] to [what] ???
> I'm not aware of any program which can transfer a file using your
> current ssh session. scp, rsync, & others expect to make their own
> connections to the remote system, and then close that connection when
> the file transfer is complete.
This is true, and it's usually the best way to do things. I thought about
this, though, and came up with an inefficient and kludgy way to transfer stuff
using an interactive ssh session and a couple of evil Perl scripts:
#!/usr/bin/perl -w
# file2hex.pl
$i=0;
while(read(STDIN,$l,1)!=0){
printf "%02x ",ord($l);
$i++;
if($i==15){ print "\n"; $i=0; }
}
# end
#!/usr/bin/perl -w
# hex2file.pl
while($l=<>){
chomp $l;
@a=split(/ /,$l);
foreach $c (@a){ print chr(hex($c)); }
}
# end
2 konsole tabs/whatever, one on machine1 , one on machine2:
machine1:~$ file2hex.pl < somefile | more
machine2:~$ hex2file.pl > somefile
Copy screenful of hex, paste into other session, hit spacebar, repeat until
done, hit Ctrl-D on machine2 session after last screenful pasted. Net result
is to transfer somefile from machine1 to machine2.
This is really a terrible idea, and if you can transfer the files in any other
way, it's preferable. But it does seem to work.
--
Matt G / Dances With Crows
The Crow202 Blog: http://crow202.org/wordpress/
There is no Darkness in Eternity/But only Light too dim for us to see
More information about the PLUG-discuss
mailing list