SCP 更改文本文件内容

mzh*_*ase 6 ssh scp

我正在尝试从机器 A 复制文件:

apt policy openssh-client
openssh-client:
  Installiert:           1:7.2p2-4ubuntu2.4
Run Code Online (Sandbox Code Playgroud)

到机器 B:

apt-cache policy openssh-client
openssh-client:
    Installiert: 1:5.5p1-6+squeeze5
Run Code Online (Sandbox Code Playgroud)

在 A:

scp myfile <server>:/myfile
md5sum myfile
2ba67c5e816350d4d2e2e7fd883037e7
file myfile
myfile: Python script, ASCII text executable
Run Code Online (Sandbox Code Playgroud)

在 B 上:

md5sum myfile
8883620c2a0878da1db273101b55124d
file myfile
myfile: ASCII Java program text
Run Code Online (Sandbox Code Playgroud)

查看文本文件,似乎每一行都比最后一行多一个空格,所以不是:

import argparse, os, sys

from subprocess import check_output

def count_voicemails(dir):
    # find is faster than ls, since it does not check attributes
    command = 'find {}/INBOX -maxdepth 1 | wc -l'
    count   = int(check_output(command.split()))
    return count
Run Code Online (Sandbox Code Playgroud)

它看起来像这样:

import argparse, os, sys

from subprocess import check_output

 def count_voicemails(dir):
       # find is faster than ls, since it does not check attributes
           command = 'find {}/INBOX -maxdepth 1 | wc -l'
               count   = int(check_output(command.split()))
                   return count
Run Code Online (Sandbox Code Playgroud)

Jen*_*y D 14

您的 scp 命令将文件发送到目标服务器的根目录 - 您正在 scp:ing 到/myfile. 当您稍后查看文件时,您没有提供完整路径。看起来好像您曾经尝试使用配置为从前一行插入缩进的编辑器复制文件的内容,这就是您正在查看的文件。