Posts

Showing posts with the label perl

Automatic FTP upload when content changed in folder - perl script

This was rudimentary script needed to edit more, but found interesting . #! perl -slw use strict; use Win32::ChangeNotify; use threads; #monitoring path. my $path = 'c:\folder'; my $notify = Win32::ChangeNotify->new( $path, 0, 'FILE_NAME' ); my %last; @last{ glob $path . '\*' } = (); my $count = 0; while( 1 ) { next unless $notify->wait( 10_000 ); # Check every 10 seconds $notify->reset; print $/, 'Something changed'; my @files = glob $path . '\*'; if( @files> scalar keys %last ) { my %temp; @temp{ @files } = (); delete @temp{ keys %last }; #print for keys %temp; my $k; my $v; while ( ($k,$v) = each %temp ) { my $thr1 = threads->create(\&load, $k,$count); } } else { print "A non-deletion or creation change occured"; } undef %last; @last{ @files } = (); $count = $count +1; } sub load { my...

Mikrotik Backup through perl script

I don't know how many people are still using telnet but suppose if you are using this will help. Script uses export command to take the backup and save it. I thought better to share it. I'll check the ssh variation and upload when possible. #Date - 31st April 2010 #Gobinath #To retrive the backup from the mikrotik router. #!/usr/bin/perl use Net::Telnet; use POSIX ; #Input # routerlist contains ipaddress and name that save the backupfile seprated by tab # used for comments. #Backup Path. $path = "/mikrotik/backups"; #router List $filename = "routerlist.txt"; #Mikrotik Username Password +ct used to remove the color codes @username_list = ('admin+ct','admin'); @password_list = ('######','######'); #Read the router List open (FILE,$filename) ; #Time Stamp. my $datestamp = strftime("%Y%m%d",localtime); chomp($datestamp); sub retriver { undef @output ; my($username, $pass,$hostname) = @_; $telnet = new Net::Telnet (...