Using mailx
Posted in 2000
Topics: General Discussion
Hi I'm trying to use mailx command within a cron script but it doesn't work. The script grabs the e-mail address field from the "weekly_check" file (8 th field) and moves it to the variable "kod". After that it should run mailx to the receiver "kod". if [ -s "/home/it/hq/internet/weekly_check" ] then for X in /home/it/hq/internet/weekly_check do kod=cat | cut -d"|" -f8 /home/it/hq/internet/weekly_check mailx -s "Internet Weekly Warning Report $(date "+%d/%m/%y %H:%M") " $kod@forex.com < /home/it/hq/internet/formatted_int_report.txt done fi Here is a sample : weekly_check file : 746|YKK METAL PLAST'K|FETE|THASU|80065|x|FBAKYKK|W06|23/03/2000| 862|OTOMOT YA |NLIK|CAESF|22356|e|eraf34d|BS2|31/03/2000| ^ This field is the kod. The Shell output is this : W06 BS2 @forex.com... user address required It seems that it doesn't recognise the e-mail address. Cheers
Ilhan Erden wrote: > I'm trying to use mailx command within a cron script but it doesn't > work. The script grabs the e-mail address field from the "weekly_check" > file (8 th field) and moves it to the variable "kod". > After that it should run mailx to the receiver "kod". This has almost nothing to do with Informix per se -- the weekly_check file is probably an Informix unload file, though, so we'll let you off. It is a pure shell question. > if [ -s "/home/it/hq/internet/weekly_check" ] > then > for X in /home/it/hq/internet/weekly_check > do > kod=cat | cut -d"|" -f8 /home/it/hq/internet/weekly_check The previous line is missing some back-quotes or $(...) stuff. I also think that the cat is irrelevant - you only need cut. > mailx -s "Internet Weekly Warning Report $(date "+%d/%m/%y > %H:%M") " $kod@forex.com < > /home/it/hq/internet/formatted_int_report.txt The nested double quotes make me nervous; they do work in Korn shell, but I'd use single quotes around the date format specifier. > done > fi > > Here is a sample : > > weekly_check file : > > 746|YKK METAL PLASTÝK|FETE|THASU|80065|x|FBAKYKK|W06|23/03/2000| > 862|OTOMOT YA |NLIK|CAESF|22356|e|eraf34d|BS2|31/03/2000| > ^ > This field is the > kod. > The Shell output is this : > W06 > BS2 This comes from the invocation of kod=cat etc. > @forex.com... user address required So, have you run the script manually, under ksh -x? Is cron using Bourne shell, in which case the $(...) notation does not work? Have you used a command to list the arguments one per line: #include <stdio.h> int main(int argc, char **argv) { while (*++argv) puts(*argv); return(0); } I have such a command and it often helps me find out what's up with argument spacing more easily than either 'sh -x' or echo does. > It seems that it doesn't recognise the e-mail address. Well, it does recognize that you supplied '@forex.com' as the email address and it is complaining that this is not a valid email address -- and it isn't. -- Yours, Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h> Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN "I don't suffer from insanity; I enjoy every minute of it!"