Reputation: 299
I have written some script files in my PC with Windows7, then I upload these files to remote Linux computer. The system on remote computer is :
Debian 3.14.15-2 (2014-08-09) x86_64 GNU/Linux
by uname -a
. With ls
command I see the files are successfully uploaded to the expected directory:
xxx@ion:/mnt/backup/TIEGCM2/saturation_2.0$ ls
Apr_P_150_res5.0.job Apr_P_200_res5.0.job Apr_P_100_res5.0.job
these files are C shell script:
xxx@ion:/mnt/backup/TIEGCM2/saturation_2.0$ file Apr_P_200_res5.0.job
Apr_P_200_res5.0.job: C shell script, ASCII text executable, with CRLF line terminators
However, when I run one of them with nohup, it throw error "No such file or directory":
xxx@ion:/mnt/backup/TIEGCM2/saturation_2.0$ nohup ./Apr_P_200_res5.0.job &
[3] 17065
xxx@ion:/mnt/backup/TIEGCM2/saturation_2.0$ nohup: ignoring input and appending output to 'nohup.out'
nohup: failed to run command './Apr_P_200_res5.0.job': No such file or directory
[3]+ Exit 127 nohup ./Apr_P_200_res5.0.job
The file exists of course which could be proven by ls
. The more strange thing is, when I written scripts directly in Linux systems by vi
, then it will run without any problem. When I created a script file in Linux, download to my Windows7 PC, modified content but keep filename untouched, and then uploaded to Linux; the script file will run without any problem. However, if I created a script file in Linux, download to my Windows7 PC, modified content and the filename, and then uploaded to Linux; the script file will refuse to run and throw "No such file or directory" error.
So what's wrong?
Upvotes: 0
Views: 6652
Reputation: 4574
The below line in your output indicates you're having dos line-endings "CR - Carriage returns" in your file.
with CRLF line terminators
Try running cat -v your_file
, if it shows ^M at the end of each line you'd need to run dos2unix
on them, eg dos2unix your_file
to convert them to unix format
Upvotes: 3