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
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:
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:
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
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.
Can you provide more information about your environment?
What OS are you using?
What version of perl are you using?
What shell are you running the script from?
What is your PATH?
What user are you running this script as? What user do you run the working script as?
Have you removed the second quotation mark identified by jambesh in an earlier response and tried the script again?
Provide as much detail as you can - it helps to eliminate the guesswork on our side.