0

This scipt gives proper result, but also gives mistake:$'\r': command not found in line with query.

#!/bin/bash
keyOrPass=$1
intercom=$2
flat=$3
number=$4
mysql -ulogin -ppass dbname -e "select cli.codeGuestEmail, cli.codePrivateEmail, cliKey.rf_id, cliKey.emailNotification from mbus_clients as cli join mbusClientKeys as cliKey on cliKey.id_client=cli.id WHERE cli.flat=${flat} and cli.domophone=${intercom};";

This is how I run the script:

 sh sendEmailNotification.sh key 10001014 11 1
Sal00m
  • 2,938
  • 3
  • 22
  • 33
Sergey Scopin
  • 2,217
  • 9
  • 39
  • 67

2 Answers2

1

Create a version of your script without Windows line delimiter \r:

tr -d "\r" < sendEmailNotification.sh > sendEmailNotification_fixed.sh
Cyrus
  • 84,225
  • 14
  • 89
  • 153
0

Check and fix line-endings in your script, probably, it was saved with \r\n as line delimiters.

This link may be useful: How to convert DOS/Windows newline (CRLF) to Unix newline (\n) in a Bash script?

Community
  • 1
  • 1
Slava Semushin
  • 14,904
  • 7
  • 53
  • 69