Command
perl -i -wpe 'BEGIN{undef $/} s/\/\/[^\n\r]*(\n\r)?//g; s!/\*.*?\*/!!sg;' <file-name>
perl -i -wpe 'BEGIN{undef $/} s/\/\/[^\n\r]*(\n\r)?//g; s!/\*.*?\*/!!sg;' <file-name>
[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 :
[perl] Install perl module without answer "yes"
PERL_MM_USE_DEFAULT=1 perl -MCPAN -e 'install Net::SSH::Perl'
Reference :
[perl] How to install the module of perl
Install Net::Telnet
cpan Net::Telnet
Reference :
[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 :
[Perl] The book of Perl
[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 :
[Perl] How to fix "Can't locate Device/SerialPort.pm"
1. Change to root
sudo su
2. Type cpan
3. Type " install Device::SerialPort", then start to install package.
Another Question :
Q : 'YAML' not installed
A: Type "install YAML ", then start to install package.
Reference :