I have several files in various sub-directories that I would like to scp over to a remote host using a shell script. I have a manifest text file with all the file names and paths listed. However, trying to run scp on every file in the list gives me "No such file or directory". I am using a Git Bash terminal on Windows 10.

The manifest.txt file with all the file names listed:

directory1/file1.elf
directory1/file2.elf
directory2a/file3.a
directory2b/file4.o

When I try to run

while read -r LINE; do scp ${LINE} [email protected]<IP_ADDRESS>:/home/root; done < manifest.txt

I get : No such file or directoryle1.elf (on my terminal it appears that that the file name gets squished together with the error).

The odd thing is, when I run

while read -r LINE; do echo ${LINE}; done < test_manifest.txt

I get all the file names listed as expected (it matches the format of manifest.txt).

When I try to scp each file over individually, e.g. scp directory1/file1.elf [email protected]<IP_ADDRESS>:/home/root, the file transfer works correctly, so I am wondering what I am doing incorrectly?

1 Answers

0
Alex Yefimov On

Aaron's comment actually lead to solving the issue! Indeed I had originally created manifest.txt in Windows (I use Sublime Text). In Sublime Text, I changed View > Line Endings to "Unix" (from "Windows") and now the files copy over correctly. (Or as Aaron suggests, the dos2unix tool).