using sendmail in system(cmd)


 
Thread Tools Search this Thread
Top Forums Programming using sendmail in system(cmd)
# 1  
Old 08-10-2005
using sendmail in system(cmd)

In 'C' I am trying to use the sendmail to send a message that program completed successful or failed.

The syntax is:
sprintf(cmd,"/usr/sbin/sendmail roncayenne@ssss.org to: roncayenne@ssss.org from:root subject: PROGRAM SUCCESSFUL .");
system(cmd);

But this is not working. Seems it does not like anything after the sendmail address and does not recognize the period at the end.
Anyone know what is wrong with the above. Thanks!

Ron
# 2  
Old 08-10-2005
sendmail will work but we use a simpler way -- mailx:
Code:
EmailId = string which is email address
textfile can be empty or have message text in it - the file must exist
    and be referenced by a pathname -- strcpy(textfile,"/path/to/textfile");
    
sprintf (cmd, "/usr/bin/mailx -s '%s' %s < %s", "Status Report", EmailId,textfile);
system (cmd);

This sends the mail as the current owner of the process.
# 3  
Old 08-10-2005
I sure wish we had mailx on our box but we don't so I am trying to get the sendmail to work. Any ideas on the syntax that would be similar to what you showed on mailx?
Thanks for the info and the reply...
# 4  
Old 08-10-2005
This was tested and works on HPUX:
Code:
#include <stdlib.h>
int main()
{
    char message[24]={0x0};
    char cmd[128]={0x0};
    const char *EmailId="jmcnama@piffl.com";
    strcpy(message,"all is well");
    sprintf(cmd, "echo \"%s.\" | sendmail %s ",message,EmailId);
    system(cmd);
    return 0;

}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sendmail cmd for html body and attachment not working

Hi, I am having trouble in sending a mail with html body and attachment (csv file). We don't have uuencode or mutt (not allowed to install as well) The below code is perfectly working for sending the html body alone: export MAILTO=abc@xyz.com export CONTENT="/home/abc/list.html"... (2 Replies)
Discussion started by: close2jay
2 Replies

2. Shell Programming and Scripting

Invoking system(cmd) inside awk command

Hi, I was searching for a way to grep 2 lines before and after a certain keyword, and I came across the following code.. awk "\$0 ~ /ORA-/ { cmd=\"awk 'NR>=\" NR-2 \" && NR<=\" NR+2 \"' init.ora\" system(cmd) }" input_file I could not understand how this works. What is system() ? what... (2 Replies)
Discussion started by: Kulasekar
2 Replies

3. UNIX for Advanced & Expert Users

sendmail error - 452 4.3.1 Insufficient system resources

Hi All, I am using svnnotify (which is available on net) script to send svn commit notification. Everything was working fine up to yesterday but from yesterday i started seeing error. 29CD01FCE44 7228 Thu Apr 5 11:11:51 apache@vm0001.host.com (host mail.mailserver.com said: 452... (6 Replies)
Discussion started by: vishal_vsh1
6 Replies

4. Shell Programming and Scripting

Perl open(CMD, "cmd |"); buffering problem..

Hello, There's a third-party application's command that shows the application's status like "tail -f verybusy.log". When use the command, the output comes every 1-sec. but when it goes in a script below the output comes every 8-sec...What is the problem and how can I fix it? open(CMD,... (2 Replies)
Discussion started by: Shawn, Lee
2 Replies

5. UNIX for Dummies Questions & Answers

Sendmail process "Toomany" system slowing down

Hello Experts I have M4000 Solaris 10 server, from few many days there are too many sendmail and mail.local process starting on server and each time i need to kill mannualy using pkill send mail, some time there will 600 of them taking 30mb memory for each and hence slowing down the server,... (2 Replies)
Discussion started by: karghum
2 Replies

6. Shell Programming and Scripting

Unix cmd prompt how to get old cmd run?

Hi, I am using SunOS I want to serch my previous command from unix prompt (like on AIX we can search by ESC -k) how to get in SunOs urgent help require. (10 Replies)
Discussion started by: RahulJoshi
10 Replies

7. Shell Programming and Scripting

Capturing awk's system(cmd) output

Hi everybody, I am working on a bigger awk script in which one part is comparing the size of two files. I want to evaluate which file is bigger and then just save the bigger one. I got it all working except for the part where I want to figure out which file is bigger; the one awk is currently... (2 Replies)
Discussion started by: iMeal
2 Replies

8. Programming

How to get system() function executed cmd return value ?

Hi, How I can get system function executed command return value ? I want to know mv command success or not ? #include <stdio.h> main() { int ret; ret = system( "mv x.dat y.dat" ); printf( "system ret:\n", ret ); } (3 Replies)
Discussion started by: haiudhaya
3 Replies

9. UNIX for Dummies Questions & Answers

man <cmd> >> cmd.txt

I've noticed most of my postings here are because of syntax errors. So I want to begin compiling a large txt file that contains all the "man <cmd>" of the commands I most have problems with. I ran a "man nawk >> nawk.txt" but it included a header/footer on each "page". Anyone know how I'd be... (6 Replies)
Discussion started by: yongho
6 Replies

10. Shell Programming and Scripting

perl "system" cmd return values..

perl 5.6.1: when i try a "system" command(with if loops for $?), i get this: child exited with value 1 what is meant by this $? values and what does it meant if it returns 1?.. (0 Replies)
Discussion started by: sekar sundaram
0 Replies
Login or Register to Ask a Question