Shell脚本SCP返回代码1

Shell脚本SCP返回代码1,shell,Shell,我正在使用shell脚本scp命令使用ssh将一个文件从一个服务器移动到另一个服务器。 我的命令如下所示: scp -P 23 -i $TEST_SSHKEY $DESTINATION_PATH/$FILETOCOPY $USER_ID@$SERVER_BOX: 文件正在复制,但scp返回的返回代码为1 为什么会发生这种情况,解决办法是什么?G'day 尝试启用详细模式(-v)以查看更多详细信息,而不是只查看返回代码1(表示“发生了不好的事情”)。我也有同样的问题。问题是远程端的服务器没有发送

我正在使用shell脚本scp命令使用ssh将一个文件从一个服务器移动到另一个服务器。 我的命令如下所示:

scp -P 23 -i $TEST_SSHKEY $DESTINATION_PATH/$FILETOCOPY $USER_ID@$SERVER_BOX:
文件正在复制,但scp返回的返回代码为1

为什么会发生这种情况,解决办法是什么?

G'day


尝试启用详细模式(-v)以查看更多详细信息,而不是只查看返回代码1(表示“发生了不好的事情”)。

我也有同样的问题。问题是远程端的服务器没有发送退出代码。比较这些交易摘录

第一个原因是
$?=1

debug1: Sending command: scp -v -f /cfg/running-config
Sink: C0644 3398 running-config
running-config                                     100% 3398     3.3KB/s   00:00    
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Connection to xxxxx closed by remote host.
Transferred: sent 2576, received 5216 bytes, in 1.9 seconds
Bytes per second: sent 1346.9, received 2727.3
debug1: Exit status -1
第二个原因是
$?=0

debug1: Sending command: scp -v -f /cfg/running-config
Sink: C0644 3940 running-config
running-config                                     100% 3940     3.9KB/s   00:00    
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Connection to xxxxx closed by remote host.
Transferred: sent 2624, received 5984 bytes, in 1.3 seconds
Bytes per second: sent 2026.8, received 4622.2

这是两个不同固件版本的HP交换机。第一个非常古老;第二个是新的,正确地将
退出状态回复0
返回给客户端。

您的线路似乎正常。返回代码1是有关选项/参数的一般错误。当命令运行时,很奇怪。。。多发布一点shell脚本可能会有所帮助……感谢您的回复,但详细输出返回-1退出状态。@prathibha,您是否尝试过该命令的其他形式?ssh-p23-i-2是否仅使用协议2?或者尝试将用户指定为-l,而不是@