![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem, with if condition in function | gurukottur | Shell Programming and Scripting | 4 | 04-24-2008 02:57 PM |
| How to configure mail function on Solaris | raman1605 | SUN Solaris | 2 | 03-20-2008 04:58 AM |
| PERL function problem | avadhani | Shell Programming and Scripting | 2 | 06-15-2005 04:18 AM |
| mail problem (NOT Mail or Mail.app) | chenly | UNIX for Dummies Questions & Answers | 1 | 05-29-2002 12:59 PM |
| rexec() function problem | lcmoreno | High Level Programming | 7 | 01-08-2002 10:19 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
mail function problem
Hello all,
I'm attempting to sent an e-mail with the following funtion in my script. The tested that the logic is correct with another native os command, but I can't seem to get mail to work. I played with the "", just can't seem to get it right. Any ideas? Thanks. $my_mail = `mail -s`; sub mail { $my_mail "test" my.name@company.com < /dev/null; } db_util.pl" 59 lines, 869 characters ./db_util.pl String found where operator expected at ./db_util.pl line 57, near "$my_mail "test"" (Missing operator before "test"?) Bareword found where operator expected at ./db_util.pl line 57, near ""test" my" (Missing operator before my?) Array found where operator expected at ./db_util.pl line 57, at end of line Bareword found where operator expected at ./db_util.pl line 57, near "/dev/null" (Missing operator before null?) syntax error at ./db_util.pl line 57, near "$my_mail "test"" Execution of ./db_util.pl aborted due to compilation errors. |
|
||||
|
You have the quotes the wrong way, and don't put a dollar sign when declaring a variable. Also no spaces around the equals sign. The shell is a harsh mistress.
Code:
my_mail='mail -s' |
|
||||
|
Oops! Egg on my face.
Still, you can't invoke it like that; the backticks evaluate there and then, which is not what you want. And, you can't pass parameters like redirection like that in a Perl script. Code:
sub mail
{
open (MAIL, '| mail -s "test" spamtrap@example.com') || die "anguish: $!";
close MAIL;
}
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|