Hello. I linked two servers together, to transfer files via .sh script.

Created a test.sh file with content:

scp -P 22 /file/my_file.conf root@IP_SERVER:/folder/file.txt 

If you run this file through the Shell client with the command: sh /folder/test.sh file is transferred to the server, but you cannot open this file, it is broken.

And if you just run the command in the Shell client: scp -P 22 /file/my_file.conf root@IP_SERVER:/folder/file.txt - the file is transferred and as it should be, not broken.

What can be wrong?

  • for starters, I would compare file sizes. Perhaps the file is simply not transmitted to the end - KoVadim
  • @KoVadim is possible. but why is it not transmitted to the end? because if you just execute the file transfer command, it is transmitted correctly. And if you run the file in which the commands for file transfer are registered - it transmits broken files ... - iKey
  • so team or team? it is quite possible that many, many files are being transmitted and somewhere else a timeout occurs. - KoVadim 2:24 pm
  • @KoVadim initially had 5 file transfer commands. I also thought that this was the case, but no, I removed all the commands except one - the result is the same. Yes, and the files there are 2kb in size - iKey
  • one
    Of course, I would like to see the difference between these files, but if it switched to cat, then maybe the problem of string translation manifested itself in some way? - KoVadim

0