Mailx command in unix shell script, its throwing below error


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Mailx command in unix shell script, its throwing below error
# 1  
Old 01-12-2012
Mailx command in unix shell script, its throwing below error

How to use Mailx command in unix shell script, its throwing below error
Code:
#!/bin/ksh
let x=3
If  [ $x  -gt 2 ]  ; then
mailx  -s “ $x is greater than 2” example@gmail.com  << EOF
This is the message body
EOF
fi

its throwing error as syntax error at EOF
--------------------------------------------------------------
i tried as below even then no luck
Code:
mailx  -s “ $x is greater than 2” example@gmail.com


Shell script is not executing anything......not throwing error

Can someone help me ?????

Last edited by Scott; 01-12-2012 at 01:20 PM.. Reason: Added code tags; removed email address
# 2  
Old 01-12-2012
Quote:
Originally Posted by only4satish
its throwing error as syntax error at EOF
Smilie Throwing what syntax error?
# 3  
Old 01-12-2012
error is EOF is unexpected

---------- Post updated at 11:02 PM ---------- Previous update was at 11:02 PM ----------

Code:
error at the line "mailx  –s “ $x is greater than 2” example@gmail.com  << EOF

"

Moderator's Comments:
Mod Comment Please use next time code tags for your code and data

Last edited by vbe; 01-16-2012 at 01:18 PM.. Reason: nth code tags addition
# 4  
Old 01-12-2012
In the example posted, the word "if" has a capital letter and it should not have a capital letter. Otherwise the script as posted is sound.

Just in case, let's check the script file for funny characters and extra spaces etc..
This sed is designed to make control characters visible. A normal end of line shows as a dollar sign:

Code:
sed -n l scriptname

# 5  
Old 01-12-2012
It's staring me in the face.

This script has been edited with a Microsoft program such as Microsoft Word.
The quotes characters are “ and ” for example when they should be " and " .
A Microsoft format program code file will not work in unix or any other non-Microsoft Operating System without conversion or retyping.

My advice: Retype the script directly into a proper unix editor such as "vi" or a Linux editor such as "vim".
# 6  
Old 01-12-2012
Not even Microsoft programming languages would let you use code that's been edited in a Microsoft editor Smilie They really do mangle it...
This User Gave Thanks to Corona688 For This Post:
# 7  
Old 01-13-2012
i am trying to attach a file (file.txt) with below command, but its throwing error
Code:
(cat message ; uuencode file.txt ) | mailx -s "status" "example@gmail.com"

Error:
Code:
./mail.ksh: line 8: uuencode: not found

please help me where i have gone wrong ???

Last edited by Scott; 01-14-2012 at 02:14 PM.. Reason: Code tags. Please STOP posting your email address.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command throwing error while deleting a line from a file

Hi all, I ahve a program which has to delete a line in a file... if i run the sed command through shell prompt it works fine. But if run it using code its throwing error. May i know where i am doing wrong. the file has 3 lines # cat /root/.ssh/known_hosts... (4 Replies)
Discussion started by: vivek d r
4 Replies

2. Shell Programming and Scripting

How to echo output of a UNIX command (like ls -l ) using shell script.?

How do i echo the output of a unix command using shell script??? Like: echo /etc/ ls -l (2 Replies)
Discussion started by: sunny2802
2 Replies

3. Shell Programming and Scripting

Help me!how to run autosys command in UNIX shell script

Hi all, Here is my scenario.. i need to get dates from an existing autosys calendar and compare it with current date with in a unix shell script. Please help me out and give me an approach to handle this....... the general autosys calendar command used is autocal_asc ,but this is... (1 Reply)
Discussion started by: shrik12345
1 Replies

4. Shell Programming and Scripting

for loop with internal unix command in statement throwing error

Hi I've gotten a plugin script that won't run. I keeps throwing an error at the following line. for BARCODE_LINE in `cat ${TSP_FILEPATH_BARCODE_TXT} | grep "^barcode"` do #something done The error reads ... (3 Replies)
Discussion started by: jdilts
3 Replies

5. Shell Programming and Scripting

sendmail script throwing an error "No recipient addresses found in header"

Hi, I am using following code to send an e-mail with attachment and body. echo "To: user1@mail.com,user2@mail.com" > mail.tmp echo "Cc: user3@mail.com,user4@mail.com" >> mail.tmp echo "From: group@mail.com" >> mail.tmp echo "Subject: my report" >> mail.tmp echo "please see as attached"... (6 Replies)
Discussion started by: vivek_damodaran
6 Replies

6. Shell Programming and Scripting

Error while using sqlplus command inside 'if' condition in an unix shell script

Hi all, I am using the below given sqlplus command in my unix script to invoke a stored procedure which returns a value .It works fine. RET_CODE=$(/opt/oracle/product/10.2.0.4.CL/bin/sqlplus -S $USER/$PASSWD@$DB_NAME <<EOF EXEC MY_PKG.MY_SP (:COUNT); PRINT COUNT; commit; ... (6 Replies)
Discussion started by: Shri123
6 Replies

7. Shell Programming and Scripting

Bcc in mailx command in Unix

Hi, At present we have been using the mailx command which is working perfectly and the command is as follows; mailx -s "$DESCR1" -c $DLIST_CC -r $REPLY $DLIST We would like to add a Blind carbon copy "Bcc" in this mailing list using mailx. Please let us know how this can be done in ksh. (2 Replies)
Discussion started by: jmathew99
2 Replies

8. UNIX for Dummies Questions & Answers

forcefully throwing error : unix script

how can i make one script fail if some condition is not satisfied.i m writing if ..else logic in script.i need some standard command to do that ,, (1 Reply)
Discussion started by: dr46014
1 Replies

9. UNIX for Dummies Questions & Answers

Remote login/copy command throwing an error

Hi We had 3 server -hp112and hp146 here hp112 is production server and hp146 is staging server used for load. when i am trying to run follwing command rcp abc hp112:/dnbusr1/gbid/gbid02 it's trowing an error :- remshd: Login incorrect. But same command is working wise versa - rcp abc... (1 Reply)
Discussion started by: ashish_panpalia
1 Replies

10. Shell Programming and Scripting

How to use mail,mailx command in Shell Script ?

Hi.. How can i use mailx,mail command in Shell Script. Suppose i gave a condition that x value is above 25 send a mail alert to abc@rediffmail.com. How can i do this? Regards Sollin (16 Replies)
Discussion started by: sollin
16 Replies
Login or Register to Ask a Question