First off, what a bizarre problem to be solving. Are you certain you're solving the correct problem?

Secondly, what's happening is that you're sending the contents of $os_says to perl's eval. The code you have currently is equivalent to:

$os_says .= `$_`; eval($os_says);
What you want to do right now (as was already pointed out) is switch to:
eval { $os_says .= `$_` };

However, once you do that, you'll have the case that $@ will always be the null string, no matter if the backquoted command failed or not.(*) If you want to check on the return status of the executed command, check $!.

But let me repeat - I do not think you are doing what you want to do. First off, you're executing every line with /bin/sh, and not with /bin/csh, even if csh is your default shell. Secondly, each line is getting executed in its own subprocess, so even if you were executing the lines with csh, this two line combination would produce an "Undefined variable" error:

setenv ADP_INPUT_HOME /disk4/vendor/adp/ echo "Looking for files in $ADP_INPUT_HOME"

Now, it would be possible to open a csh shell in the background and feed it one line at a time, and I suppose you could monitor the csh shell to see if it exited, but that's a much, much more advanced problem than you seem to be aiming for here.

Why on earth are you trying to do this?

(*) Okay, so I think $@ might contain something if the system were so overloaded that a subprocess couldn't be forked to do the backquote magic.
-- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

In reply to Re: $@ with backticks inside eval by fizbin
in thread $@ with backticks inside eval by aplonis

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.