use WWW::Mechanize; ## Type IP admin ID passowrd &shutdownNAS( 'TGL', '192.168.1.100', 'admin', 'password'); &shutdownNAS( 'TGL', '192.168.1.101', 'admin', 'password'); &shutdownNAS( 'HTGL', '192.168.1.102', 'admin', 'password'); &shutdownNAS( 'HTGL', '192.168.1.103', 'admin', 'password'); sub shutdownNAS() { my ($type,$host,$id,$pass) = @_; my $mech = WWW::Mechanize->new( noproxy=>1 ); printf("Shutdown $host NAS .....\n"); if ( $type eq 'TGL' ) { $mech->get("http://$id:$pass\@$host/cgi-bin/ts.cgi?page=maintenance&mode=shutdown&type=setup&txtClickButton=shutdown"); } elsif( $type eq 'HTGL' ) { $mech->get("http://$host/cgi-bin/top.cgi"); $mech->form_name('frmNas'); $mech->field( 'txtAuthLoginUser', $id, 1); $mech->field( 'txtAuthLoginPassword', $pass, 1); $mech->submit(); $mech->form_name('frmNas'); $mech->field( 'gPage', 'maintenance', 1); $mech->field( 'gMode', 'shutdown', 1); $mech->submit(); $mech->form_name('frmNas'); $mech->field( 'gPage', 'maintenance', 1); $mech->field( 'gMode', 'shutdown', 1); $mech->field( 'gType', 'shutdown', 1); $mech->click('btnShutdownShutdownSubmit'); } printf("Shutdown Process end\n"); }