Re: [BillKSmith] Append two lines to a file through perl!!
[In reply to]

Can't Post

Hi Bill, I tried modifying with your inputs It looks like this .The Ip 1.2.3.4 is the Ip address where i want to forward my local syslogs to remote machine 1.2.3.4. I want to add this two lines in local machine syslog.conf

./newtest1.pl syntax error at ./newtest1.pl line 26, near "{" Global symbol "$syslog_filename" requires explicit package name at ./newtest1.pl line 27. Global symbol "$syslogadd" requires explicit package name at ./newtest1.pl line 29. Missing right curly or square bracket at ./newtest1.pl line 30, at end of line Execution of ./newtest1.pl aborted due to compilation errors.

Your last error message tells you that the perl compiler got to the end of your script and did not find a match for the brace "}" on line 15. Fixing this will probably fix the other "errors".

However, you missed my point. Not hard to do because I had misunderstood your problem. (I thought that the "&" was part of you text and that the "\" was an escape character) Please post an accurate sample of the output that you want. I recommend that you attach your input and output files rather than pasting them into a window.

UPDATE: Here is my best guess of what you want!

Code

#!/usr/bin/perl -w

use strict; use warnings; use IO::Prompt; use Net::OpenSSH; use Regexp::Common::net qw/net/;

my $password = prompt( 'Password: ', -echo=>'*');

open my $fh, '<', 'host-list.txt' or die "failed to open 'host-list.txt' <$!>";