6

I am trying to copy a file from machine A:

apt policy openssh-client
openssh-client:
  Installiert:           1:7.2p2-4ubuntu2.4

to machine B:

apt-cache policy openssh-client
openssh-client:
    Installiert: 1:5.5p1-6+squeeze5

On A:

scp myfile <server>:/myfile
md5sum myfile
2ba67c5e816350d4d2e2e7fd883037e7
file myfile
myfile: Python script, ASCII text executable

On B:

md5sum myfile
8883620c2a0878da1db273101b55124d
file myfile
myfile: ASCII Java program text

Looking into the text file, it seems that every line has one more space in it than the last one, so instead of:

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

It looks like this:

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
mzhaase
  • 3,798
  • 2
  • 20
  • 32
  • 3
    Are you sure you're looking at the same file? In your scp command, you're sending the file to /myfile. If you're looking at a file with the same name in your home directory, that would explain the issue. (Especially if you've already tried to copy the file into a vim edit window customized to repeat spaces at the beginning of lines.) – Jenny D Aug 16 '18 at 10:42
  • @JennyD: Beat me to it and I am 95% sure that you could write this as an answer outright :) – Sven Aug 16 '18 at 10:45
  • @JennyD goddamit, I pasted it into vim originally and then scp actually did not overwrite the destination file. – mzhaase Aug 16 '18 at 10:45
  • @mzhaase: I've never experienced this with `vim`, but in `joe` I get this problem with the evermore indentation when pasting into an SSH session all the time. – Sven Aug 16 '18 at 10:48
  • 2
    Not that I personally have ever experienced this, or a version thereof *cough* – Jenny D Aug 16 '18 at 10:54
  • 1
    And especially not spent several minutes trying to figure it out. No, sirree. – Jenny D Aug 16 '18 at 10:56
  • 1
    To avoid this indentation when pasting in vim, use `set paste`. – TonioElGringo Aug 16 '18 at 14:00
  • if an SCP is modifying your files, i would suggest contacting the Foundation. – user371366 Aug 16 '18 at 20:49

1 Answers1

14

Your scp command sends the file to the root of the target server - you're scp:ing to /myfile. When you later look at the file, you're not giving the full path. It looks as though you have once tried to copy the contents of a file using an editor configured to insert indentation from the previous line, and that's the file you're looking at.

Jenny D
  • 27,780
  • 21
  • 75
  • 114