From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Message-ID: <47022123.3020402@mail.ru> Date: Tue, 02 Oct 2007 14:44:51 +0400 User-Agent: Thunderbird 2.0.0.6 (X11/20070804) MIME-Version: 1.0 To: dimard@gmail.com, dimania@mail.ru, ALT Linux Sisyphus discussions References: <46F360A0.6020706@mail.ru> In-Reply-To: <46F360A0.6020706@mail.ru> Content-Type: multipart/mixed; boundary="------------060909050600030805040301" From: dima Subject: Re: [sisyphus] =?koi8-r?b?SFAgTEogMTAxMCDLwcsg08XUxdfPyg==?= X-BeenThere: sisyphus@lists.altlinux.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: ALT Linux Sisyphus discussions List-Id: ALT Linux Sisyphus discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Oct 2007 10:44:59 -0000 Archived-At: List-Archive: List-Post: This is a multi-part message in MIME format. --------------060909050600030805040301 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 8bit Добрый всем день! Как и обещал, ложу программку для закачки прошивки в принтер. В дальнейшем постараюсь автоматизировать процесс. -- С уважением, Русецкий Дмитрий. --------------060909050600030805040301 Content-Type: text/plain; name="fwload4dlink" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fwload4dlink" #!/usr/bin/perl -w # # Copyright 2007, Rusetsky Dmitry (dimania@mail.ru) All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of either: # # a) the GNU General Public License as published by the Free Software # Foundation; either version 1, or (at your option) any later # version, or # # b) the "Artistic License" which comes with Perl. # # On Debian GNU/Linux systems, the complete text of the GNU General # Public License can be found in `/usr/share/common-licenses/GPL' and # the Artistic Licence in `/usr/share/common-licenses/Artistic'. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # ######################################################################### # # Programm load firmware to Host based Printers over printserver Dlink DP-301U # # Usage: fwload4dlink [user[:password]@]host # # Prereq: Net::FTP, LWP::UserAgent # Version: 0.01 # ######################################################################### use strict; use warnings; use Net::FTP; use LWP::UserAgent; our $VERSION; $VERSION = '0.01'; #initial stuff my ($username, $password, $host); #get command line arguments my $pr_status = 0; my @opts = grep /^-/, @ARGV; my @other = grep /^[^-]/, @ARGV; my $server = shift @other; my $firmware = shift @other; my @arg_opts = map { split( /=/, $_ ) } grep( /=/, @opts); my %arg_opts = ( "--timeout" => "300", "--port" => "21", @arg_opts, ); map { $arg_opts{$_}++ } grep /^[^=]+$/, @opts; if ($arg_opts{"-h"} || $arg_opts{"--help"}) { print join "", ; exit(0); } unless (defined $firmware && defined $server) { print("$0 [user[:password]@]host \n"); exit 1; } print "fwload4dlink $VERSION - 2007 (c) by Dimania \n"; my $timeout = $arg_opts{"--timeout"}; my $port = $arg_opts{"--port"}; #split them my (@parts) = split /@/, $server; my ($left, $right); if (@parts <= 2) { ($left, $right) = @parts; } else { $right = pop @parts; $left = join '@', @parts; } unless (defined $right) { $right = $left; undef $left; } ($username, $password) = split /:/, $left if defined $left; $host = $right if defined $right; unless ( defined $username ) { $username = ""; } unless ( defined $password ) { $password = ""; } # Get status printer my $ua = LWP::UserAgent->new; $ua->agent("Mozilla/5.0"); # Create a request #print "http://$username:$password\@$host"; my $req = HTTP::Request->new(GET => "http://$username:$password\@$host"); # Pass request to the user agent and get a response back my $res = $ua->request($req); # Check the outcome of the response if ($res->is_success) { #print $res->content; my @string; @string = split /\r\n/, $res->content; my $i=0; while( defined( $string[$i] ) ) { if ( $string[$i] =~ /Printer Status.*:.*On.*line.*/ ) { print "Printer On line\n"; $pr_status=1; last; } if ( $string[$i] =~ /Printer Status.*:.*Off.*line.*/ ) { print "\nYour printer is Off line! Please Turn ON printer and try again.\n"; #print "Printer Off line\n"; $pr_status=0; exit; } $i++; } } else { print $res->status_line, "\n"; exit; } #make the connection by ftp my $ftp; $ftp = new Net::FTP($host, Debug => 0, Passive => 0, Port => $port); $ftp or die "Couldn't make FTP connection to $host on port $port: $@!\n"; $ftp->login($username, $password) or die "Login failure!\n"; $ftp->binary; print "Successfully logged into $host\n"; my @files = $ftp->dir(); #map { $_ =~ s|^/|| } @files; print "\nFiles: @files\n"; # Load firmware my $status = $ftp->put($firmware,"USB1"); unless (defined $status) { print "\nError load firmware to printer on port @files\n"; } else { print "\nLoad firmware to printer on port @files sucessful!\n"; } my @status = $ftp->quit(); __DATA__ This programm load firmware to Host based Printers over printserver Dlink DP-301U Usage: fwload4dlink [user[:password]@]host Examples: fwload4dlink printserver1.org lj1010.dl --------------060909050600030805040301--