G'day astronogun,

While there's quite a few issues with the code you posted, I see nothing that would prevent appending to a text file:

$ ls -l input.txt ls: input.txt: No such file or directory $ perl -e '$input = q{input.txt}; @output = system ("ls -l >> input.tx +t");' $ ls -l input.txt -rw-r--r-- 1 ken staff 16393 12 Mar 15:34 input.txt

Here's some of the issues I found with your code:

I'd suggest something like the following code as a starting point from which you can inspect return values and investigate your problem further.

$ perl -e ' use strict; use warnings; use autodie qw{:all}; my $output_file = q{output.txt}; my $return_value = system "ls -l >> $output_file"; '

You'll note both here, and earlier, that I've used a simple ls -l command to test the code. I'd suggest you do the same, to check whatever file-appending problem you're experiencing, before trying with "java -jar cmdline-jmxclient-0.10.3.jar - localhost:1100 com.ogs.red5.client.manager:name=Manager getConnectedAgents" which may have its own issues that could be masking your reported problem.

-- Ken


In reply to Re: How to print the contents of system function to a .txt file by kcott
in thread How to print the contents of system function to a .txt file by astronogun

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.