I cannot copy a file over scp when the remote machine .bashrc file includes source command to update paths and some variables. Why does it happen?
Running scp when .bashrc of remote machine includes source command
scp
scp
I cannot copy a file over scp when the remote machine .bashrc file includes source command to update paths and some variables. Why does it happen?
Best Answer
You should make part or all of your
.bashrc
not run when your shell is non-interactive. (Anscp
is an example of a non-interactive shell invocation, unless someone has radically altered your systems.) Then put all commands that can possibly generate output in that section of the file.A standard way to do this in an init file is:
You might also see people use
instead of my more verbose
if
statement.If you don't want to rearrange your whole file, you can also just make certain lines run only in interactive context by wrapping them like so:
If you segregate your
.bashrc
this way, then yourscp
commands should no longer have this problem.