当我输入scp file1 user@host.com:file2
命令提示符时,我收到消息
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
Run Code Online (Sandbox Code Playgroud)
然后我等待大约 10 秒钟,然后scp
返回到命令行。这不会发生在ssh
,只会发生在scp
. 我正在使用 Fedora 18。
Mar*_*ryl 16
您的配置文件脚本可能有一些命令需要与终端仿真进行交互会话。它们在非交互式scp
会话中执行时失败。
例如,如果您使用 bash,则应将此类命令从.bashrc
脚本移至.bash_profile
.
或者使用TERM
或PS1
环境变量或类似技巧来跳过非交互式会话的这些命令。
# 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
Run Code Online (Sandbox Code Playgroud)
这不会评估您是否用于scp
复制文件,但会评估您是否启动交互式会话。
(示例代码由@Criggie 提供)