@rem = '--*-Perl-*-- @echo off perl "%~dpnx0" %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofperl @rem '; #!perl #line 8 use strict; use warnings; use Term::ReadKey; use Net::Telnet (); use Win32::Console; my $CON = new Win32::Console(STD_OUTPUT_HANDLE); my @info = $CON->Info; my $w = $info[0]; print 'Enter Username: '; my $user = <STDIN>; chomp $user; print "Enter Password: "; ReadMode ('noecho'); my $pass = <STDIN>; chomp $pass; ReadMode ('restore'); print "\n"; my $machine = 'corus'; my @lines; my $t = new Net::Telnet (Timeout => 3600, Input_log => "c:/ftp/telnet +.log"); $t->open($machine); $t->login($user, $pass); @lines = $t->cmd("ps -ef | grep $user"); pop @lines; for ( @lines ) { my $line = $_; chomp $line; my $prefix = substr($line,0,47); $line = substr($line,47); while ( length($line) > 0 ) { print $prefix.substr($line,0,$w-47); if ( length($line) > $w-47 ) { $line = substr($line,$w-47); } else { $line = ''; } $prefix = ' 'x47; } print "\n"; } for ( @lines ) { my $pid = $1 if /${user} ([0-9]+)/; print "Kill process $pid?"; my $yn = <>; $t->cmd("kill $pid") if $yn =~ /^y$/i; } __END__ :endofperl

In reply to Remote killing of processes by PhilHibbs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.