how to copy a log file from solaris machine to windows after telnet to that machine?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • susinthaa
    New Member
    • Jun 2007
    • 30

    how to copy a log file from solaris machine to windows after telnet to that machine?

    Hi ,

    Is there any command in perl to copy a log file from solaris machine to windows machine after telnet to that machine?
    After copying how can we check that log for particular event?

    Thanks and Regards,
    Susi
  • prn
    Recognized Expert Contributor
    • Apr 2007
    • 254

    #2
    Hi susi,

    Check out the modules Net::FTP and (better) Net::SFTP for file transfer.

    As far as looking for particular events in a log file, that should be relatively easy. It just depends on looking for whatever in the log file identifies the events. Then there's the question of what to do with the events when you've found them, but that's another question.

    HTH,
    Paul

    Comment

    • susinthaa
      New Member
      • Jun 2007
      • 30

      #3
      how to copy a log file from solaris machine to windows after telnet to that machine?

      Hi,

      yes, Actually I want to confirm that whether the event occured or not.
      But if I tried that I copied the logfile in an array and i used , pattern matching .
      Even though it identifies the error, but execution did not stopped.
      Its goes to next line of execution.
      I tried the following code.

      [CODE=perl]
      print"Choose anyone of the lun name:\n";
      @line = $telnet->cmd("disk");
      print "@line";
      $movie=susintha ;
      $song=arun;
      system ("mkdir -p $movie/$song touch $movie/$song");
      open(FILE,">$mo vie/$song/file.txt");
      print FILE @line;
      close FILE;

      print "\nEnter the lun name:\n";
      chomp($lunname = <stdin>);

      open(FILE,"< $movie/$song/file.txt");
      #@lines = <LOGFILE>;
      foreach $line ( <FILE> ) {
      if($line=~ /$lunname/) {
      $flag=1;
      print"matchs";
      }
      }
      if ($flag!=1) {
      print"Enter correct lun name";
      }
      close(FILE);
      @vold=$telnet->cmd("disk $lunname stat");
      print"@vold";
      #print"susintah ";
      print"\nEnter the Volume name:\n";
      chomp($volname =<stdin>);
      [/CODE]

      In this if any user give wrong input ,it intimate the user and also give some system errors, and execution goes to next line and asking the user for volume name.

      Is there any command to stop the execution if any errors occured.
      Any ideas?

      Thanks,
      Susi
      Last edited by miller; Jun 28 '07, 07:10 PM. Reason: Code Tag and ReFormatting

      Comment

      • prn
        Recognized Expert Contributor
        • Apr 2007
        • 254

        #4
        Originally posted by susinthaa
        yes, Actually I want to confirm that whether the event occured or not.
        But if I tried that I copied the logfile in an array and i used , pattern matching .
        Even though it identifies the error, but execution did not stopped.
        Its goes to next line of execution.
        Is this how you are getting a "logfile"? Just capturing the output of a command? That is not a "logfile".
        [code=perl]
        print"Choose anyone of the lun name:\n";
        @line = $telnet->cmd("disk");
        [/code]

        Why are you bothering to save the array @line to a file? You then just open "file.txt" again and read in the file, which is equivalent to @line. You don't need to do that. Just use @line itself.

        The other problem you mentioned is that regardless of what the user enters it just keeps on. Consider something like:
        [code=perl]#! /usr/bin/perl
        use strict;

        my @line = ("lun1", "lun2", "lun3", "lun4", "lun5");
        my $flag;
        my $lunname;

        while (! $flag ) {
        print "Choose any of these lun names:\n";
        foreach my $ln (@line) { print "$ln\n"; }
        print "\nEnter a lun name:\n";
        chomp($lunname = <stdin>);

        print "lunname entered is $lunname \n";

        for (my $i=0; $i<=$#line; $i++) {
        if ( $lunname =~ /$line[$i]/ ) {
        $flag = 1;
        last;
        }
        }
        }
        print "$lunname is a valid lun\n";[/code]I just defined the array @line for this illustration, but you can see that the "while (! $flag)" construction allows you to loop until the user enters a valid lun name, i.e., one from the list.

        (Incidentally, always "use strict", it helps a lot.)

        Let us know if this does not answer your question and solve your problem.

        Best Regards,
        Paul

        Comment

        Working...