Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Perl system (mailx) is not sending the complete file

Posted on 2008-10-08
9
Medium Priority
?
590 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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
 
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 2000 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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 how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

662 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