Pages

Sending mails from the command line to multiple receipents using gnome-gmail.

Here is a script which can be used to send a common mail to all number of receipients, with all the recepient mail ids stored in a text file.

The script uses the tool gnome-gmail, which can be installed from your package repository, In debian based systems it can be installed using



Create a file called mialIds which will have a a list of mail ids to which mails need to be sent. For example



Create a file with the following script and name it as mailscript.sh



The input variable in the script should point to the file containing the mail ids.. If the script and the file containing mail ids are in the same folder, then just the name is enough.

The variable subj is used to store the content to be filled in the subject line of the mail. The variable bod will contain the text for the body of the email.

Execute the script

If you execute it the first time, gnome-gmail will prompt you to enter the gmail id that needs to be use dfor sending the email. If the gmail is in the logged in state in the browser, it will be able to send the mail automatically, else it might open the login prompt for you to login into the gmail account. Gnome-gmail Its a great way to automate sending default emails.

[: -eq: unary operator expected





The above error might come when we are using conditional operators to compare two values in a bash script. For example , conisder the following script to compare a user input number with a constant.



The above script when executed will throw the error as listed before. The error in the program is use of $ while taking the input, that is the right way of using the read command is "read without a $ symbol before the name.



The second possible reason for the error could be not passing two values to compare for the operataor , for example the script below will also throw the same error as the operator "eq" has been given only a single operand.



In the above example, we have missed passing the constant after the comparision opertaor.

Looking in the above two possibilities should fix the error.