Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-29 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found