Hi monks,

In the below script after executing the wmdist command, it is suppose to send the success status to a file ( which is in if loop). It is doing correctly. But if there is no ouput for the failed status, it is writing the previous output i.e success output to the failed text file. This should not happen. My requirement is my file should be empty if there is no output for failed status. I have tried giving system(“clear”) command after wmdist command. But while executing the program it is throwing a error “ clear is not a operable command like that”

#! /usr/bin/perl -w #use warnings; #use strict; use Net::SMTP; use MIME::Lite; ###Deleting the old files unlink <D:/report/*.txt>; ###Input from the User print "\n Pls give all your inputs in CAPS\n"; print "Enter the dist id of the package\n"; chop($input=<STDIN>); print "Enter the gateway name of the package\n"; chop($division=<STDIN>); print "Enter the version of the package\n"; chop($version=<STDIN>); ### Declarations my %id=("HTCHSTCGW1"=>"abc\@abc.in", "HTCHTDLGW1"=>"def\@def.in", "HTCHMROGW1"=>"ghi\@ghi.in", "HTCHAM4GW1"=>"jkl\@jkl.in"); my %cc=("HTCHSTCGW1"=>"ppp\@ppp.in", "HTCHTDLGW1"=>"ppp\@ppp.in", "HTCHMROGW1"=>"ppp\@ppp.in", "HTCHAM4GW1"=>"ppp\@ppp.in"); my $mail_host='10.101.26.28'; my $From_address='admin@abc.in'; my $body="Hi, Monthly Patches were distributed to the hosts in $division.\n Results of the $version patches"; ###Distribution Status based on Input if($version eq "2K") { system("wmdist -e $input SUCCESS > 2K_success.txt"); system("wmdist -e $input FAILED > 2K_failed.txt"); system("wmdist -e $input WAITING > 2K_waiting.txt"); } if($version eq "2K3") { system("wmdist -e $input SUCCESS > 2K3_success.txt"); system("wmdist -e $input FAILED > 2K3_failed.txt"); system("wmdist -e $input WAITING > 2K3_waiting.txt"); } if($version eq "XP") { system("wmdist -e $input SUCCESS > XP_success.txt"); system("clear"); system("wmdist -e $input FAILED > XP_failed.txt"); $|=1; system("wmdist -e $input WAITING > XP_waiting.txt"); } my $To_address=$id{$division}; my $cc_address=$cc{$division}; $msg=MIME::Lite->new( From => $From_address, To => $To_address, Cc => $cc_address, Subject =>'Monthly Patches Rollout Distribution Status', Type =>'multipart/mixed' ); $msg->attach( Type =>'Text', Data => "$body" ); if ( $version eq "2K3") { $msg->attach( Type =>'text/html', Path =>'D:/report/2K3_success.txt', Filename =>'2K3_success.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/2K3_failed.txt', Filename =>'2K3_failed.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/2K3_failed.txt', Filename =>'2K3_waiting.txt', Disposition => 'attachment' ); } if ( $version eq "2K") { $msg->attach( Type =>'text/html', Path =>'D:/report/2K_success.txt', Filename =>'2K_success.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/2K_failed.txt', Filename =>'2K_failed.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/2K_failed.txt', Filename =>'2K_waiting.txt', Disposition => 'attachment' ); } if ( $version eq "XP") { $msg->attach( Type =>'text/html', Path =>'D:/report/XP_success.txt', Filename =>'XP_success.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/XP_failed.txt', Filename =>'XP_failed.txt', Disposition => 'attachment' ); $msg->attach( Type =>'text/html', Path =>'D:/report/XP_failed.txt', Filename =>'XP_waiting.txt', Disposition => 'attachment' ); } MIME::Lite->send('smtp',$mail_host,Timeout=>60); $msg->send;

Is there any discrepancies found in the code.

Can anyone correct me where i am wrong.

Thanks in advance for your valuable efforts.


In reply to Error when using system("clear") command by valavanp

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.