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
3
  • And how do you call this script? you should detect the number of arguments and is lower than 4 then exit the script without executing the query Commented Oct 27, 2014 at 12:10
  • Added example of run. Commented Oct 27, 2014 at 12:12
  • 1
    Has all the hallmarks of a Windows newline. Was the script created on Windows and copied over? Commented Oct 27, 2014 at 12:13

2 Answers 2

1

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

tr -d "\r" < sendEmailNotification.sh > sendEmailNotification_fixed.sh
Sign up to request clarification or add additional context in comments.

1 Comment

You should see the Windows line delimiters with cat -v sendEmailNotification.sh.
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?

1 Comment

But it is in one line in my script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.