Email Attachment Script | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Email Attachment Script

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-03-2009
xmaverick xmaverick is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 5 February 2010, 2:02 PM EST
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Email Attachment Script

Hello,

I created the following script but i'm trying to figure out why i keep getting an error.

#!/usr/bin/perl -w
use strict;
use warnings;

my $baseDir = '/export/home/omcadmin/bin';
my $attachment = "$baseDir/message.txt";

my $from = 'xxx@xxx.com';
my $to = 'xxx@xxx.com';
my $cc = 'xxx@xxx.com';
my $subj = 'Testing';
my $body = 'TEST';


my $cmd = "uuencode $attachment |mailx, '-s',$subj, '-c', $cc, $to, "-f$from"";
system ("$cmd");



The error i receive is:
email.pl: use: not found
email.pl: use: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: my: not found
email.pl: syntax error at line 19: `system' unexpected



Any suggestions?
Sponsored Links
    #2  
Old 09-03-2009
avronius avronius is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 22 May 2013, 8:38 AM EDT
Location: Calgary
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
My first guess is that it appears to not be finding perl, but is instead trying to run as a shell program... See if perl exists in the location that your script is checking:

Code:
ls -ail /usr/bin/perl

If it returns a message indicating perl: No such file or directory, you will need to find out where perl IS installed, and update your script with the proper path information:

Code:
which perl

or

Code:
find / -name perl -print

Sponsored Links
    #3  
Old 09-03-2009
jambesh's Avatar
jambesh jambesh is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 29 March 2012, 1:48 AM EDT
Location: California,USA
Posts: 153
Thanks: 0
Thanked 0 Times in 0 Posts
Seems your $cmd = ..... statement has wong double quote -
Try -
my $cmd = "uuencode $attachment |mailx -s $subj -c $cc $to -f $from";
Why are you making single quote around the mail options ?

I don't think it is require

You can check where perl is installed at the first place and then provide the path to perl interpreter
Check where perl installed and the version


perl -V
    #4  
Old 09-03-2009
xmaverick xmaverick is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 5 February 2010, 2:02 PM EST
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Perl is installed in the directory in which im running my script
Sponsored Links
    #5  
Old 09-03-2009
jambesh's Avatar
jambesh jambesh is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 29 March 2012, 1:48 AM EDT
Location: California,USA
Posts: 153
Thanks: 0
Thanked 0 Times in 0 Posts
can you just paste the out put of your perl path from which perl command

You can check if the path to the module are in @INC path ?
type in command promt :

perl -e 'use strict;'

if your path are ok this should work fine
Sponsored Links
    #6  
Old 09-03-2009
xmaverick xmaverick is offline
Registered User
 
Join Date: Aug 2009
Last Activity: 5 February 2010, 2:02 PM EST
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
What should happen when i execute the perl -e 'use strict;' on the command prompt. I didn't get anything on the prompt.

---------- Post updated at 11:24 AM ---------- Previous update was at 11:22 AM ----------

If i attempt to execute a different script it will work from the directory in which i'm running the current script that fails. This tells me that the path is correct.
Sponsored Links
    #7  
Old 09-03-2009
avronius avronius is offline
Registered User
 
Join Date: Apr 2008
Last Activity: 22 May 2013, 8:38 AM EDT
Location: Calgary
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
identify a script that is working.

Code:
head -1 scriptname

Ensure that this line matches the line that starts your script.

Last edited by avronius; 09-03-2009 at 11:36 AM.. Reason: Fixed grammar
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Email with Attachment piyushprabhakar AIX 5 07-10-2008 06:10 AM
how to deattach attachment of email kandati UNIX for Dummies Questions & Answers 4 03-04-2005 05:29 AM
script that will send and email attachment davels Shell Programming and Scripting 2 01-01-2005 04:44 AM
Email Attachment Cyro UNIX for Dummies Questions & Answers 2 11-10-2003 09:24 AM
Email Attachment prasad01 UNIX for Dummies Questions & Answers 2 08-07-2003 02:43 PM



All times are GMT -4. The time now is 12:37 AM.