LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-06-2004, 04:10 AM   #1
seran
Member
 
Registered: Aug 2004
Location: Bangalore
Posts: 64

Rep: Reputation: 16
Angry scp: copy a file from local machine to remote machine


Hi,
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.


Thanks
Seran
seran@mindteck.com
 
Old 08-06-2004, 04:44 AM   #2
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
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

regards
 
Old 08-06-2004, 08:12 AM   #3
ReefShark
Member
 
Registered: Oct 2003
Location: the Netherlands
Distribution: Arch Linux, Ubuntu server
Posts: 145

Rep: Reputation: 15
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
Code:
# 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.
 
Old 08-06-2004, 11:50 AM   #4
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
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

regards
gaurav
 
Old 08-09-2004, 01:00 AM   #5
rkdugar
LQ Newbie
 
Registered: Jul 2004
Posts: 13

Rep: Reputation: 0
Try to set the env variable TERM using the following comand:

TERM=xterm; export TERM

Try scp now..it should work...

Cheers,

rkdugar
 
Old 08-09-2004, 01:12 AM   #6
seran
Member
 
Registered: Aug 2004
Location: Bangalore
Posts: 64

Original Poster
Rep: Reputation: 16
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?

Thanks
Seran
 
Old 09-01-2005, 06:57 AM   #7
andybuckley
LQ Newbie
 
Registered: Sep 2005
Location: Durham, UK
Distribution: Fedora, Scientific Linux & Debian
Posts: 1

Rep: Reputation: 0
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":
Code:
## 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!

Andy
 
Old 03-22-2006, 10:37 PM   #8
seran
Member
 
Registered: Aug 2004
Location: Bangalore
Posts: 64

Original Poster
Rep: Reputation: 16
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.
.....
clear
/usr/games/fortune
echo

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.
 
Old 10-30-2007, 12:23 PM   #9
grantc
LQ Newbie
 
Registered: Jun 2005
Location: Spain
Distribution: SuSE 9.3, Ubuntu 5.04, FC3/4
Posts: 2

Rep: Reputation: 0
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 http://www.gnu.org/software/bash/man...ref.html#SEC75. I used the following example to detect if my shell was interactive or not:

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

regards

grant
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SCP: Copy file from remote linux server onto a windows machine? Tony Empire Linux - Newbie 21 09-22-2015 10:18 PM
trying to copy files from another machine to the local machine using telnet,..how? shrike_912 Programming 6 03-14-2006 04:45 PM
scp/ssh tail(multiple file) remote copy tpreitano Linux - General 1 08-22-2005 02:17 PM
how to open a dilog on local machine when i do ssh to remote machine fahad26 Programming 3 05-03-2005 07:39 PM
scp :copy file from one remote comp to another aniketh Linux - Networking 4 06-16-2004 02:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration