Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Perl system (mailx) is not sending the complete file

Posted on 2008-10-08
9
Medium Priority
?
593 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

885 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