6

When I type scp file1 [email protected]:file2 into the command prompt, I get the message

Can't open display
Can't open display
Can't open display
Can't open display
Can't open display
file1                          100%  589KB 589.0KB/s  00:00

And then I wait for about 10 seconds, before the scp returns to the command line. This does not happen with ssh, only with scp. I am using Fedora 18.

2
  • Would you mind to try an absolute path, e.g.: scp file1 [email protected]:/home/user/file2 ? Commented Dec 17, 2019 at 10:27
  • Same thing happens. Commented Dec 17, 2019 at 10:30

1 Answer 1

16

Your profile scripts probably have some commands that expect an interactive session with a terminal emulation. And they fail when executed in a non-interactive scp session.

For example, if you are using bash, such commands should be moved from .bashrc script to .bash_profile.

Or use TERM or PS1 environment variable or similar trick to skip those commands for a non-interactive session.

# If running interactively, then:
if [ "$PS1" ]; then

#### Alex's funky commands might go here                          <------
    /usr/bin/ssh-agent &

    # If this is an xterm set the title to user@host:dir
    case $TERM in
    xterm*)
        PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
#### Alex's funky commands might also go here if they apply to xterm sessions  <------
        ;;
    *)
        ;;
    esac

fi

This will not evaluate if you use scp to copy a file, but will if you start an interactive session.

(The sample code is by @Criggie)

5
  • 1
    You are correct, it's the commands in .bashrc that were causing this to happen. Commented Dec 17, 2019 at 10:43
  • 1
    Would you share what those commands were, or some information about them, @Alex? Commented Dec 17, 2019 at 20:50
  • There were xrandr commands intended to detect which screens are present, and to arrange them in an appropriate order. Commented Dec 18, 2019 at 7:40
  • I thought scp used a special sftp subsystem rather than doing a regular SSH login. Commented Dec 18, 2019 at 19:08
  • @Barmar 1) scp does not use SFTP subsystem. 2) Even sftp would suffer the same problem - SFTP still runs over SSH login. Commented Dec 19, 2019 at 7:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.