in reply to Passing the contents of a file in a "system" call to a .ksh script

As previous posters have pointed out, you are passing the name, not the content, of the log file to the command - a more concise means (than shown elsewhere in this thread) of achieving the same end would be along the lines of...
my ($LOGFILE, @content) = ("/home/admin/logs/check_jvm/check_jvm_$LOGT +IME.log"); open LOG, "<$LOGFILE" or die "open($LOGFILE) failed - $!"; chomp(@content = <LOG>); close LOG; my @args = ("/home/admin/bin/email.ksh", @content, "Web Server Issue", + "PROD", "/home/admin/logs/check_jvm/EmailAlert.log"); system(@args) == 0 or die "system @args failed: $?"
Update: Added call to chomp ... for, hopefully obvious reasons ;-)

Thanx to fullermd - changed @LOG to @content & removed quotes (it's already in list context) in assignment of/to <c>@args>/c>

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^2: Passing the contents of a file in a "system" call to a .ksh script
by fullermd (Vicar) on Jan 09, 2009 at 03:15 UTC
    my @args = ("/home/admin/bin/email.ksh", "@LOG", "Web Server Issue", " +PROD", "/home/admin/logs/check_jvm/EmailAlert.log");

    ITYM

    my @args = ("/home/admin/bin/email.ksh", @content, "Web Server Issue", + "PROD", "/home/admin/logs/check_jvm/EmailAlert.log");

    (and the @content up at the top by $LOGFILE doesn't do anything either...)

      In that context yes, TFT fullermd - I forgot the whole thing's in list context so @content doesn't need stringifying. As for the the occurrence (of @content) at the top, it does do something, it satisfies the strictures (I assumed they were present but not shown).

      A user level that continues to overstate my experience :-))
        I forgot the whole thing's in list context so @content doesn't need stringifying.

        Oh, it's not the context; it's that you were passing @LOG, which was never set to anything.

        As for the the occurrence (of @content) at the top, it does do something, it satisfies the strictures

        Ah, I see. I'm leery of writing it that way; it looks too much like a bug, like you meant to assign something to it there.