Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-19-2013, 03:17 AM   #1
LQ Newbie
Registered: Apr 2008
Posts: 6

Rep: Reputation: 0
Unhappy weird conflict with scp and "echo" in cshrc


I'm working on a SUSE enterprise 10 ENV. Let's name this server as "servername".

My default login sh is tcsh. Recently, i add a new line to update the terminal title in the ~/.cshrc, like below:
echo -n "\033]0;${HOST}\007"

Then i found the remote "scp" command, launching the "scp" from another box to fetch data from it, won't work any more. Below is the output:
$ scp foo@servername:~/.cshrc ./
C0444 158 .cshrc

And if removing the new "echo" line, everything will be fine.

Could you please share your knowledge on this issue?

Thanks in adv.

Last edited by sleepy_11; 12-19-2013 at 03:20 AM.
Old 12-19-2013, 11:04 AM   #2
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,714

Rep: Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280Reputation: 1280
don't do that.

Test for a terminal before doing the echo. If no terminal is attached, don't do it.

What is happening is that the echo violates the file transfer protocol.

The way that works is that scp makes an initial connection, authenticates... and waits for a signal to start data transfer operation. I think that signal is a null byte sent by scp running as a child process of the sshd daemon. Setting up this client requires the sshd to fork a shell which initializes by processing the .cshrc and .login files... If those scripts cause an output, then the protocol is violated, and scp running locally terminates, which also terminates the sshd daemon and the remote scp client.

You can try something like:
if($?prompt) then               # Only interactive shells set $prompt
    echo -n "\033]0;${HOST}\007"
You can also test terminal usage by a
if [ "`tty`" != "not a tty" ]; then

Last edited by jpollard; 12-19-2013 at 11:19 AM. Reason: error in my update. sorry about that.
1 members found this post helpful.
Old 12-19-2013, 07:49 PM   #3
LQ Newbie
Registered: Apr 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Great thanks for your wisdom, jpollard.

The issue is gone with the second option. Also learned more with the explanation.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Running "script" command from .bashrc/.cshrc zeke666 Linux - General 17 04-16-2012 10:11 PM
A question about "echo "$CALLER" | tr -s '[:upper:]' '[:lower:]'" thomas2004ch Linux - Software 5 03-13-2012 03:57 PM
why to commit .cshrc "source .cshrc" file in every new shell session simer_anand88 Mandriva 3 10-23-2009 10:44 AM
BASH: How to NOT echo to screen with "if echo $x | grep ".*"; then" eur0dad Programming 9 07-27-2006 03:14 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:10 AM.

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