Grabbing [and removing] remote files

While SSH’d into a remote machine, I find that I need to grab a file to use it locally. But, I’m behind a firewall … and so is the server, which means I can’t scp the file to or from my machine. I resort to temporarily dropping the file on an intermediate machine accessible by both.

After doing this for a while I ended up with a lot of junk piled on the intermediate machine because I never clean up files after copying them to my lappie.

Using a recently discovered rsync option, --remove-source-files, I created an alias which does the cleanup for me:

alias grabrm='rsync --remove-source-files'

I now after copying the file to the intermediate machine:

remote_machine$ scp foo.txt intermediate:

I run the following command, which copies the file and removes it from the intermediate machine:

local_machine$ grabrm intermediate:foo.txt .

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s