1

This question already has an answer here:

I get this after rsync the .sh file to the server:

sudo: unable to execute ./run_vps_post_config.sh: No such file or directory

To fix, I open the file with winscp and save it. Then it runs again. (this is nothing to do with permissions. It runs ok.)

Same thing happens when I zip->rsync->unzip. However if I unzip with -aa option (treat ALL files as text), then it is OK.

I looked in rsync for a similar option to treat files as text, but none was found.

marked as duplicate by Kusalananda shell-script May 30 at 15:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • how are you creating the file on your local system? Have you set the executable bit on the shell script on the remote file? Can you give an ls -l of the script on the remote side? – Tim Kennedy May 30 at 15:14
  • So, you have a Windows server and some Unix server, and the file was written on the Windows machine using a Windows text editor? Then your files are DOS text files (with an extra carriage-return character at the end of each line). Run dos2unix on them on the Unix server before trying to use them, or get your Windows text editor to save the files as Unix text file from the start, or just do your development on the Unix system as any sane person would :-) – Kusalananda May 30 at 15:15
  • @ Tim Kennedy -rwxrw-r-- 1 user user 6561 May 30 15:24 run_vps_post_config.sh yes of course I chmod u+x – conanDrum May 30 at 15:25
  • @Kusalananda dos2unix is what I needed thanks please post it as an answer. – conanDrum May 30 at 15:28
  • 1
    I marked it as a dupe instead of answering. We have more than a handful of questions with similar issues (files created on, or modified on, a Windows system, then transferred to Unix), and the solution is always to convert the files to Unix text files from DOS text files. Adding the same answer again would not add benefit for you or future readers. – Kusalananda May 30 at 15:51

Browse other questions tagged or ask your own question.