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,902
  • 3
  • 20
  • 32
Sergey Scopin
  • 2,187
  • 8
  • 34
  • 64

2 Answers2

1

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

tr -d "\r" < sendEmailNotification.sh > sendEmailNotification_fixed.sh
Cyrus
  • 77,979
  • 13
  • 71
  • 125
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,371
  • 7
  • 50
  • 68