0

Here's are the commands I've tried (in a .sh file).

rcp $1/target/$1*SNAPSHOT.jar remote_server:~/

rsync -v $1/target/$1*SNAPSHOT.jar remote_server:~/

Both of these create a file on remote_server named ? (i.e the full path is ~/?, instead of just using the same name as the original file (like ~/xx.jar). The $1 is the name of the folder/jar file, I give it a single value. So for example, ./upload.sh test.

I'm sure I'm just missing something simple.

Remote OS is Amazon Linux 2 (basically CentOS). My OS is WSL Ubuntu (Ubuntu running on Windows).

  • 3
    Add set -x before your rcp or rsync command in the script, and show what happens when running the script. This will show you what command is actually being run, and is helpful in making sure what is actually happening, what you think is happening, and what you have scripted to happen are all the same thing (please add this detail as an edit to your question, and not as a reply to this comment). – DopeGhoti Mar 15 at 19:24
  • The ~/ on the target side is not needed. The home directory is usually the default. Note that the target should still end in :. – Kusalananda Mar 15 at 19:33
  • the charset on WSL might not be UTF8 as is almost always the case on current Linux – A.B Mar 15 at 20:00
  • Just got around to this: thanks for the set -x pointer! You were right that the executing command was different from expected. It turns out a ? was being appended to the rsync and rcp because of line endings. Running dos2unix fixed the problem for me. I had been wondering why the problem was only on one PC too, makes sense now since git doesn't handle line endings that well. – rococo Mar 22 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.