An alternative to opening a pipe as graff suggests (which is a perfectly find solution) is to make an executable shell script that does everything you want and then invoke it with a single system call. This has the advantage that it will probably be useful to you on the commandline as well. For example, make a file called ~/bin/foo and make it executable and contain the source:
#!/bin/csh source /exlibris/aleph/a16_1/aleph/proc/unset_lib_env if( $? != 0 ){ exit 1 } # i guessed at the whole syntax here source `/exlibris/aleph/a16_1/aleph/exe/dev_aleph gpo01`/gpo01/prof_li +brary if( $? != 0 ){ exit 2 } # i guessed at the whole syntax here echo $data_root if( $? != 0 ){ exit 3 } # i guessed at the whole syntax here
Note invoke it like $rc = system('/home/yourname/bin/foo'); And then you can inspect $rc >> 8 for the actual exit code to see if it error'd or not. (see perldoc -f system for more details)

Side note: Csh Programming Considered Harmful

re: your original code -- note that the $data_root will be interoplated by perl .. to avoid that and pass the literal $data_root to echo you have to escape it like "$program echo \$data_root" or better yet use the multi-parameter syntax of system (perldoc -f system) and do system($program, 'echo $data_root');

In reply to Re: Perl system calls in csh Not executing! by davidrw
in thread Perl system calls in csh Not executing! by Anonymous Monk

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.