in reply to Re^2: Write to rsyslog
in thread Write to rsyslog

> I'm supposing the OP wants to know how to use system or `backticks` in Perl, because calling CLI programs directly is interwoven into bash

LanX, given your insightful "that's similar to how I migrated from Bash to Perl" reply to this node's "Perl" code:

system ('grep -l "DATAmessage.*3\.0" *.xml > 3.0_files_arraydata.txt') +; system ("mv temp_3.0_files_onixarraydata.txt 3.0_files_arraydata.txt") +; system ("cat *files_arraydata.txt > data2.txt"); system ("rm data2.txt");

it seems you would know. :-)

Once the OP posts the working bash script, I trust we could rewrite it in Perl a bit more cleanly than the above monstrosity.

See Also

References Added Later

Updated: many references were added long after the original reply was made

👁️🍾👍🦟

Replies are listed 'Best First'.
Re^4: Write to rsyslog
by LanX (Saint) on May 16, 2024 at 11:33 UTC
    system is a tool, and like every tool it can be used for the better or for the worse.

    I'm not a big fan of rules becoming dogmas.

    Many modules on CPAN are just wrappers around system commands. I used one from corion at work wrapping 7zip.

    We can't know how monstrous the OP's code is, we only know it would be easier to reply if he showed it.

    At least this solves his "one line in bash" claim.°

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    see Wikisyntax for the Monastery

    Update

    °) correction, he said "simple echo statement", which is still kind of a miracle. The appropriate command is logger as far as I can Google..

    I don't advice doing any system echo ...