简体   繁体   中英

Running Shell script written in linux on windows OS

i have shell script written in RedHat OS. I need to run this script in windows environemtn.

So i used cygwin to run the script on windows.

But when i run the script using

sh housekeeper.sh 

it gives me following error which is not retured in RedHat OS

line 12: $'\r': command not found

but line number 12 of my script is empty

  08  #
  09  ######################################################################
  10  #### PARAMETERS TO SET BEGIN
  11  ######################################################################
  12  
  13  # archive setttings
  14  ARCHIVE_USER=abc                      # archive storage user name  (default)
  15  ARCHIVE_GROUP=app                     # archive storage user group (default)
  16  ARCHIVE_PATH=/test/file               # archive storage directory (default)
  17  ARCHIVE_DELAY=+8

could anybody tell me whats wrong with the script here or cygwin here.

thanks in advance for any help

Most likely cygwin sh is expecting a UNIX line separator (ie \\n ) but is instead finding a Windows line separator, \\r\\n , and hence is trying to execute \\r as if it were a command. This could easily have happened if you edited this script in a Windows-based text editor.

If you have the command dos2unix you could use that, or tr to remove \\r s:

tr -d '\r' < old.sh > new.sh

在Windows上对此文件运行dos2unix命令,然后尝试运行此文件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM