in reply to Re: exec, system, or backticks
in thread exec, system, or backticks

I need to capture the output from the Expect script so that it can be evaluated and this is why the backticks were used, but if the ouput from the Expect script ($swbt_dms) can be captured without the use of backticks this would be great. The arguement ($item) provided to the Expect script is either Datakit or IP info. So with all of this said, what would be the most appropriate method of capturing into a file (has to be into a file) the output from the Expect script so that it can be evaluated? Hay, thank you for taking time to help me with elevating my Perl knowledge.

Replies are listed 'Best First'.
Re^3: exec, system, or backticks
by ikegami (Patriarch) on Oct 20, 2004 at 17:33 UTC

    I'm not sure what you mean by evaluate. If you mean executed as perl code, how about eval ``:

    $ perl -e 'eval `echo print 1+3`'; 4

    Otherwise, system will do just fine:

    $ perl -e 'system("echo bla > file");' $ cat file bla
      What I mean by evaluate is this, the output from the Expect script is sent to a file where the sub ck_results opens the file and checks to determine if the necessary information was collected or not and then closes the file. For example, the Expect asks the other box/server to provide it specific register information so that anaylsis of this information can be done.
        To capture the output, just do:
        my $output = `$swbt_dms $item`;
      Thank you for your help my code was modified as follows: <code> system("$swbt_dms $item > $log/$key"); <code> It work just fine. Thank you again!