-   Linux - Newbie (
-   -   scp: copy a file from local machine to remote machine (

seran 08-06-2004 05:10 AM

scp: copy a file from local machine to remote machine
This is Seran. I tried to copy a file from my local machine to a remote machine using the scp (Secure Copy) linux command. This is what I gave:

$ scp <filename> seran@<ip address of remote>:<target dir>

It asked my password and after entering it, I got the following error message.

TERM environment variable not set

In my machine the value of the TERM environment variable is 'linux'.
Using ftp I was able to copy. Why scp is giving problem.
Can any one explain me how to trace the problem.


masand 08-06-2004 05:44 AM

hi there
just check that if u can login with ssh on that machine
i think ssh needs to b running for scp to work


ReefShark 08-06-2004 09:12 AM

If he is asked for his password, I suspect ssh is running on the destination host. If not, it's a trick I would love to learn ;)

First of all, whenever I run into weird stuff with ssh or scp, I use the -v (verbose) option. It often enables you to see where something goes wrong and where you might find the solution. It also provides people that could help you with useful information.
Also, try to log on to the server with ssh and type

# echo ${TERM}
I'm just taking a poke here, but perhaps the term variable of your login is not set on the destination server. If it is not, you could edit the .profile file in your homedir yourself and add it.

masand 08-06-2004 12:50 PM

hi there

what i was saying is that is he able to log in to that machine using ssh

so we can say that ssh is running fine


rkdugar 08-09-2004 02:00 AM

Try to set the env variable TERM using the following comand:

TERM=xterm; export TERM

Try scp should work...



seran 08-09-2004 02:12 AM

I did. I set the TERM env variable to xterm.
And I tried to scp. But I got the same message.

TERM environment variable not set.

In my remote machine the value of TERM is 'xterm'.
I was able to use ssh and login without any problem,
but what's wrong with scp?


andybuckley 09-01-2005 07:57 AM

It's a year later, so guess this isn't a directly useful answer, but I just encountered a similar problem and, since this is one of the very few places online to mention the scp / TERM variable problem, I thought I'd post the solution I found.

My problem was that in my .bashrc file I had used the "clear" shell builtin command to refresh the terminal, but the "dumb" terminal type used by scp doesn't support that operation, hence the (rather misleading) error. The answer was to only execute the "clear" if the terminal is not "dumb":

## in .bashrc
test "dumb" != $TERM && clear
## as opposed to just calling "clear" without thinking about terminal support

I initially tried to solve this by only calling clear from within an "if [ $PS1 ]; then ..." block (to detect an interactive shell) but that didn't work on all machines... some systems still set the PS1 variable even if it isn't an interactive shell.

You may also need to do a similar protection on the "trap" command, if you use that to clear the terminal on logout from a remote machine.

Hope that's helpful to someone, eventually!


seran 03-22-2006 11:37 PM

I just wanted to share my solution which I found. In my remote machine's /etc/bashrc file the following three lines were present at the end.

I know the root passwd of the remote machine, so I commented first, "clear" and then tried to scp from my machine. I didnt get the "TERM environment variable not set" error, but I got the fortune message on my screen and file was also not copied. Then I commented "/usr/games/fortune"(now both clear and fortune lines are commented) and tried, no error message was displayed and file was not copied.

At last I commented all the last three lines "clear", "fortune", and "echo". Now I was able to do scp.

Thanks for taking interest and giving some suggestions.

grantc 10-30-2007 01:23 PM

For what it is worth, nearly three years on from the original thread. Bash has a variable that indicates whether the shell is interactive or not. Have a look at I used the following example to detect if my shell was interactive or not:


case "$-" in
*i*)        echo This shell is interactive ;;
*)        echo This shell is not interactive ;;



All times are GMT -5. The time now is 09:21 AM.