Solved

Perl system (mailx) is not sending the complete file

Posted on 2008-10-08
9
575 Views
Last Modified: 2013-12-27
I have done this a half dozen time successfully.  I have a perl file on a Solaris OS system.  At the end of the program I want it to send the last file created.  
The command I am using is
system ("mailx -r OurGroup\@domain.net -s \"Email Subject\" My.Name\@domain.net </home/myname/criticals/logs/thefile.data");

Instead of getting the entire file, I am getting the first column (before the tab) of each line (except the first line).
The file reads&
Node                            NodeAlias                       AlertGroup                   Summary                         Tally       Acknowledged        

CFTC - 2nd Floor UPS            172.21.131.225                                               lgpEventConditionEntryAdded: This notification is sent each time a condition is inserted into the conditions table.    909            1        
       

CFTC - 2nd Floor UPS            172.21.131.225                                                lgpEventLowBatteryWarning: The battery's remaining charge is less than  or equal to the agent's configured low threshold 'lgpPwrConfigLowBatteryWarningTime'.                  255            1                

CFTC - 2nd Floor UPS            172.21.131.225                                                lgpEventConditionEntryRemoved: This notification is sent each time a co ndition is removed from the conditions table.   909            1        
       

CFTC - 2nd Floor UPS            172.21.131.225                                                lgpEventBatteryTestFailed: The device has reported a battery self-test  failure.                        190            1                

CFTC - 2nd Floor UPS            172.21.131.225                                                lgpEventLoadTransferedToBypass: The device has transfered the load to t he bypass source.               192      
 

Instead I am getting
Node                                NodeAlias                           AlertGroup                          Summary                             Tally       Acknowledged            

CFTC - 2nd Floor UPS

CFTC - 2nd Floor UPS

CFTC - 2nd Floor UPS

CFTC - 2nd Floor UPS

CFTC - 2nd Floor UPS
 
Like I said, I have done this many times and this is the first time I have had this problem.
 
0
Comment
Question by:cmaries
  • 3
  • 3
  • 2
9 Comments
 
LVL 6

Expert Comment

by:wwnosal
ID: 22672192
have you tried to that a bit differently:

system ("cat your_file | mailx  -r OurGroup\@domain.net -s \"Email Subject\" My.Name\@domain.net ");

is this shows the same behaviour?


0
 
LVL 28

Expert Comment

by:FishMonger
ID: 22676392
Why not use the MIME::Lite module to send the email?

http://search.cpan.org/~rjbs/MIME-Lite-3.021/lib/MIME/Lite.pm
0
 

Author Comment

by:cmaries
ID: 22680429
Thank you both for your comments.
wwnosal -- I tried your suggestion and I got the same results.  From a command prompt when I type cat your_file,  I get the entire file but when I run the command in the .pl I only get "the first segment of each line.

FishMonger -- I don't want to circumvent this issue, by using a different tool.  Maybe I will consider this as a last resort.

Thanks again.
0
 

Author Comment

by:cmaries
ID: 22680518
If it helps...this is how each line is created in the file

for (my $x=1; $x<$size_report-5; $x=$x+1){
     $report[$x] =~s/^\s+//;
     $report[$x] =~s/\s+$//;
     $temp = $report[$x];
     $temp = sprintf("%-30s",$report[$x]);
     $newline = $newline . $temp;
     if(substr($report[$x],0,2) =~ /^\-+/) {$newline = "";}
     if(substr($report[$x],0,5) =~ /^Tally/ || $report[$x] =~ /^\d+\s+\d+/) {
          print "nline $newline\n\n\n";
          print FILE1 "$newline\n\n";
          $newline = "";
     }
}


0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:wwnosal
ID: 22680966
Can you attach an example of the file that is causing the problems?

0
 

Author Comment

by:cmaries
ID: 22686097
I did...scroll up.  Look for "The file reads" and "Instead I am getting".  This is the file I am trying to send with the command
system ("mailx -r OurGroup\@domain.net -s \"Email Subject\" My.Name\@domain.net </home/myname/criticals/logs/thefile.data");

I also included the section of the perl file that reads the raw data file and creates this file...
 for (my $x=1; $x<$size_report-5; $x=$x+1){
    $report[$x] =~s/^\s+//;
    $report[$x] =~s/\s+$//;
    $temp = $report[$x];
    $temp = sprintf("%-30s",$report[$x]);
    $newline = $newline . $temp;
    if(substr($report[$x],0,2) =~ /^\-+/) {$newline = "";}
    if(substr($report[$x],0,5) =~ /^Tally/ || $report[$x] =~ /^\d+\s+\d+/) {
         print "nline $newline\n\n\n";
         print FILE1 "$newline\n\n";
         $newline = "";
    }
}

0
 
LVL 6

Expert Comment

by:wwnosal
ID: 22686522
yeah but exactly the output of this script is what I want to see..
0
 
LVL 28

Accepted Solution

by:
FishMonger earned 500 total points
ID: 22687086
Rather than doing a copy/paste of file and posting it in the html, use the "Attach File" option, which is just below the Comment box, and attach the file as a link so that we can see its exact contents.

See if building the system call like this makes any difference.

my @email_args = (
                               'mailx',
                               '-r OurGroup@domain.net',
                               '-s "Email Subject"',
                               'My.Name@domain.net',
                               '< /home/myname/criticals/logs/thefile.data',
                              );

system(@email_args);
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now