I am using Windows Subsystem for Linux (wsl) to run a bash script to copy a database file from a remote server to my local PC with the following command:
ssh administrator@192.168.X.X "mysqldump -uroot -ppassword databaseName" > databaseName.sql
The command works and copies the db perfectly, but as soon as I put another line below it:
ssh administrator@192.168.X.X "mysqldump -uroot -ppassword databaseName" > databaseName.sql
sleep 5
the copied db gets a dot .
(but the dot is in the middle of the line) at the end of the name like: databaseName.sql.
<-- But like I said, this second dot is a bit higher up, in the middle of the line.
When I look at the file name on the server before it gets copied, it is: 'databaseName.sql'$'\r'
Now the problem goes away when I add a ;
at the end of the ssh line like:
ssh administrator@192.168.X.X "mysqldump -uroot -ppassword databaseName" > databaseName.sql;
sleep 5
But then I get a bash message that says line 1: $'\r': command not found
. Apart from this message everything else works fine, since the error does not interrupt the rest of the script. But I would like to know why this happens without the ;
at the end, since the file is unusable with the dot at the end.
Some error searching is leading me to think that there may be a space added to the end of the line when the file gets dumped or something like that...