CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Need a Custom or Prewritten Perl Program?: I need a program that...: Re: [UnixAAP] Append two lines to a file through perl!! : Edit Log


Apr 11, 2014, 5:42 AM

Views: 20203
Re: [UnixAAP] Append two lines to a file through perl!!

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!

#!/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' <$!>";

while ( my $host = <$fh> ) {
chomp $host;
if ( $host !~ /^RE{net}{IPv4}$/ ) {
warn "$host is not in IPv4 format.\n";
print "Adding files to $host";
my $ssh = Net::OpenSSH->new("root\@$host");
$ssh->error and die "Couldn't establish SSH connection: " . $ssh->error;
my $syslog_filename = "/etc/syslog.conf";
open my $ADD, '>>', $syslog_filename
or die "Could not open '$syslog_filename' <$!>";
print {$ADD} "# Forward messages to server by IP\n";
print {$ADD} ".*.\@",
close $ADD;

Good Luck,

(This post was edited by BillKSmith on Apr 12, 2014, 11:54 AM)

Edit Log:
Post edited by BillKSmith (Veteran) on Apr 11, 2014, 4:16 PM
Post edited by BillKSmith (Veteran) on Apr 12, 2014, 11:54 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives