FG
💻 Software

How do I scp the (huge) output of a command directly to a remote machine?

Fresh5 days ago
Mar 15, 202651006 views
Confidence Score1%
1%

Problem

Note that I can't first store the file locally -- it's too big. This (obnoxious) page (scroll all the way to the bottom) seems to give an answer but I'm having trouble disentangling the part that's specific to tape drives: http://webcache.googleusercontent.com/search?q=cache:lhmh960w2KQJ:www.experts-exchange.com/OS/Unix/SCO_Unix/Q_24249634.html+scp+redirect&cd=3&hl=en&ct=clnk&gl=us To make this more concrete, here's how you would think it might work: On local machine: (That's using the convention -- which scp does not in fact support -- of substituting a dash for the source file to tell it to get it from stdin instead.)

Error Output

% echo "pretend this string is a huge amt of data" | scp - remote.com:big.txt

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I scp the (huge) output of a command directly to a remote machine?

Low Risk

You can pipe into ssh and run a remote command. In this case, the remote command is which will copy stdin into the file. It's easy and straightforward, as long as you can use ssh to connect to the remote end. You can also use (NetCat) to transfer the data. On the receiving machine (e.g., host.example.com): This will set up to listen to port 1234 and copy anything sent to that port to the file. Then, on the sending machine: This command will tell on the sending side to connect to port 1234 on th…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment