Reconstructed SHELL program:

#!/bin/sh TEMPFILE0=/home/h150371a/file.tmp TEMPFILE1=/home/h150371a/file1.tmp sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -A -media -hoursago + 24 |sed ' s/\|/ /'|awk '{print $1}' > $TEMPFILE0 cat $TEMPFILE0 | while read Image do sudo /usr/openv/netbackup/bin/admincmd/nbemmcmd -listmedia -me +diaid $Image | grep -iE 'Media ID|Data Expiration' >> $TEMPFILE1 done if [ -s "$TEMPFILE1" ] then mailx -s "Daily" ishonbackup.nar@capgemini.com < $TEMPFILE1 fi rm $TEMPFILE1 -MP # rm $TEMPFILE0

The only way I see this becoming faster in perl is if you do not write the files to disk, at expense of more RAM usage during execution.

NetWallah already did a good job of presenting you sample code... except you would get multiple emails instead of a single one... might want to replace that.

maybe this (also untested)

my @MEDIA; for (qx<sudo /usr/openv/netbackup/bin/admincmd/bpimagelist -A -media - +hoursago 24>){ s/\|/ /; my ($Image) = split; for (qx<sudo /usr/openv/netbackup/bin/admincmd/nbemmcmd -listmedia - +mediaid $Image>){ next unless m/Media ID|Data Expiration/i; push @MEDIA, $_; } } if(@MEDIA){ open(FF, "|/usr/bin/mailx -s 'Daily' ishonbackup.nar\@capgemini.com" +) or die $!; for (@MEDIA){ print FF $_ . "\n"; } close FF; }

In reply to Re: Shell script to Perl by FreeBeerReekingMonk
in thread Shell script to Perl by ansh_1415

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.