顯示具有 Perl 標籤的文章。 顯示所有文章
顯示具有 Perl 標籤的文章。 顯示所有文章

2014年6月29日 星期日

2014年5月7日 星期三

[C][Coding Style Check] Check C / C++ Coding Style by using perl script

[C][Coding Style Check] Check C / C++ Coding Style by using perl script

1. This script is fixed from checkpatch.pl

I took off the function which will check the folder of kernel root.



2. Download from Webpage

After download, please rename if from raw.pl to checkpatch.pl



3. Execute by following command


perl checkpatch.pl --file --terse ./xxxxxx.c



--file           => check a source file\n

--terse          => one line per report\n



Reference :



2013年9月20日 星期五

[perl] How to connect to server by using ssh


[perl] How to connect to server by using ssh



#!/usr/bin/perl



use Net::SSH::Expect;



my $ssh = Net::SSH::Expect->new (

        host => "172.30.144.226",

        port => "22",

        user => "ubee",

        password => "ubee1234",

        raw_pty => 1,

        timeout => '20',

        #log_file => "$TempLogFile"

        );



my $login_output = $ssh->login();



if ($login_output !~ /nl-ams99z-cnr7/) {

        die "Login has failed. Login output was $login_output";

};



$ssh->exec("cd /tftpboot/66");

my @Output = $ssh->exec("ls");



print "@Output\n";



$ssh->close();



Reference :



2013年9月19日 星期四

2013年9月18日 星期三

[perl] Ping6 to Ipv6


[perl] Ping6 to Ipv6



#!/usr/bin/perl

use strict;

use Net::Ping;



my $ip_address = $ARGV[0];

chomp($ip_address);





#Using System Command



my $retval=system("ping6 -c 2 $ip_address");



if ($retval==0) {

    print "Success!\n";

} else {

    print "Fail!\n";

}



print "\n\n\ Step2: $retval\n\n";



Reference :



2013年1月14日 星期一

[Perl] How to communicate serial port by using perl program


[Perl] How to communicate serial port by using perl program



#!/usr/bin/perl



use Device::SerialPort;



my $port = Device::SerialPort->new("/dev/ttyUSB0");

$port->databits(8);

$port->baudrate(115200);

$port->parity("none");

$port->stopbits(1);

$port->read_char_time(0);

$port->read_const_time(20);





$port->lookclear;

$port->write("cli ? \r");



sleep(2);

while (1) {

    my ($rb, $byte) = $port->read(1);

    if ($rb > 0) {

        print $byte;

    } else {

        last;

    }

}



Reference :