http://www.perlmonks.org/?abspart=1;displaytype=displaycode;node_id=635437;part=1
http://www.perlmonks.org/?node_id=635437
http://cpansearch.perl.org/src/JMCNAMARA/Spreadsheet-WriteExcel-2.37/examples/csv2xls.pl
http://unix.stackexchange.com/questions/158254/convert-csv-to-xls-file-on-linux
Tuesday, December 22, 2015
Wednesday, November 18, 2015
Download ebook recursively
http://stackoverflow.com/questions/273743/using-wget-to-recursively-fetch-a-directory-with-arbitrary-files-in-it
wget -r --no-parent ftp://ftp.ni.com/pub/events/
wget -r --no-parent ftp://ftp.ni.com/pub/branches/uk/
wget -r --no-parent ftp://ftp.ni.com/pub/events/
wget -r --no-parent ftp://ftp.ni.com/pub/branches/uk/
Tuesday, October 13, 2015
Modify Screen Saver Timeout in Registry
Modify Screen Saver Timeout in Registry
1. Start > Run > regedit
2. Find "ScreenSaveTimeOut"
3. Click and modify the value
1. Start > Run > regedit
2. Find "ScreenSaveTimeOut"
3. Click and modify the value
Monday, October 12, 2015
Windows Task Manager - kill task and list task
References:
http://www.addictivetips.com/windows-tips/kill-processes-from-the-command-prompt-in-windows-7/
https://technet.microsoft.com/en-us/library/bb491009.aspx
1. List Task List
C:\> Tasklist
2. Kill Tasks in single command
C:\> TaskKill /f /im excel.exe
http://www.addictivetips.com/windows-tips/kill-processes-from-the-command-prompt-in-windows-7/
https://technet.microsoft.com/en-us/library/bb491009.aspx
1. List Task List
C:\> Tasklist
2. Kill Tasks in single command
C:\> TaskKill /f /im excel.exe
Thursday, July 2, 2015
Perl Gmail SMTP
Credit to :
http://robertmaldon.blogspot.sg/2006/10/sending-email-through-google-smtp-from.html
# Remember to enable to allow less secure app to login the account
http://robertmaldon.blogspot.sg/2006/10/sending-email-through-google-smtp-from.html
# Remember to enable to allow less secure app to login the account
#!/usr/bin/perl -w use Net::SMTP::SSL; sub send_mail { my $to = $_[0]; my $subject = $_[1]; my $body = $_[2]; my $from = 'cybertech@company.com'; my $password = 'Pass'; my $smtp; if (not $smtp = Net::SMTP::SSL->new('smtp.gmail.com', Port => 465, Debug => 1)) { die "Could not connect to server\n"; } $smtp->auth($from, $password) || die "Authentication failed!\n"; $smtp->mail($from . "\n"); my @recepients = split(/,/, $to); foreach my $recp (@recepients) { $smtp->to($recp . "\n"); } $smtp->data(); $smtp->datasend("From: " . $from . "\n"); $smtp->datasend("To: " . $to . "\n"); $smtp->datasend("Subject: " . $subject . "\n"); $smtp->datasend("\n"); $smtp->datasend($body . "\n"); $smtp->dataend(); $smtp->quit; } # Send away! &send_mail('cybertech@cybertechcom', 'Testing is working', 'Should try this out!');
Wednesday, July 1, 2015
Configuring Samba RHEL
Credit references to:
http://www.debuntu.org/samba-how-to-share-files-for-your-lan-without-userpassword/
http://www.techotopia.com/index.php/Sharing_Files_between_RHEL_6_and_Windows_Systems_with_Samba
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s2-samba-configuring-cmdline.html
http://www.techotopia.com/index.php/Sharing_Files_between_RHEL_6_and_Windows_Systems_with_Samba
https://www.youtube.com/watch?v=yDA8DOHDaRg
https://aaronwalrath.wordpress.com/2011/03/26/install-samba-server-on-red-hat-enterprise-linux-6scientific-linux-6/
http://www.linuxexplorers.com/2014/04/configure-samba-share-in-red-hat-enterprise-linux-7-rhel7/
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/Reference_Guide/s1-iptables-saving.html
# Share with defined user to read and write permission
http://www.debuntu.org/samba-how-to-share-files-for-your-lan-without-userpassword/
http://www.techotopia.com/index.php/Sharing_Files_between_RHEL_6_and_Windows_Systems_with_Samba
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s2-samba-configuring-cmdline.html
http://www.techotopia.com/index.php/Sharing_Files_between_RHEL_6_and_Windows_Systems_with_Samba
https://www.youtube.com/watch?v=yDA8DOHDaRg
https://aaronwalrath.wordpress.com/2011/03/26/install-samba-server-on-red-hat-enterprise-linux-6scientific-linux-6/
http://www.linuxexplorers.com/2014/04/configure-samba-share-in-red-hat-enterprise-linux-7-rhel7/
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/Reference_Guide/s1-iptables-saving.html
Now we need to make changes to the “iptables” firewall startup config file. Backup the file and edit:
# cp /etc/sysconfig/iptables /etc/sysconfig/iptables.bak
# vi /etc/sysconfig/iptables
Add the first line accepting packets on TCP/445. Be sure and add it above the last line of the “input” chain with the “Reject” target, that way the rule will be processed.
-A INPUT -p tcp --dport 445 -j ACCEPT-A INPUT -j REJECT --reject-with icmp-host-prohibited
Then RESTART IPTABLE service
# service iptables restart
Configuring the smb.conf File
# Edit smb.conf
[cyber@cybertech ~]$ sudo vi /etc/samba/smb.conf
[sudo] password for cyber:
# Share with defined user to read and write permission
[ITshare]
comment = IT scripts folder
path = /home/itshare/
valid users = cyber
public = yes
writeable = yes
printable = no
create mask = 0777
browseable = yes
# Share without prompt login and able to read and write permission
[ITshare]
comment = IT scripts folder
path = /home/itshare/
write list = guest # This allow guest to write without login
read only = No
create mask = 0777
guest ok = Yes
# Share without prompt login and able to read and write permission
[ITshare]
comment = IT scripts folder
path = /home/itshare/
write list = guest # This allow guest to write without login
read only = No
create mask = 0777
guest ok = Yes
[WWW]
comment = Web Hosting Folder
path = /var/www/
valid users = cyber root
public = yes
writeable = yes
printable = no
create mask = 0777
browseable = yes
# Restart SMB service
[cyber@cybertech ~]$ sudo service smb restart
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]
Perl SQL query looping in Range of dates
Credited to http://stackoverflow.com/users/725418/tlp and http://stackoverflow.com/users/338059/sid-burn
http://stackoverflow.com/questions/19724688/perl-loop-through-months-in-a-specified-range
http://stackoverflow.com/questions/6622818/what-is-the-optimal-way-to-loop-between-two-dates-in-perl
# The Perl script below is trying to loop each day in a range of dates and perform SQL date query
#!/usr/bin/perl -w
use strict;
use Net::SSH::Any;
use DateTime;
use feature 'say';
my $hostname = "10.x.x.x";
my $username = "USER";
my $password = "PASS";
my $cmd = "";
my $output = "";
my $target_date = "";
my $start_date = DateTime->new(year => 2015, month => 1, day => 1);
my $end_date = DateTime->new(year=>2015, month => 7, day => 1);
my $ssh = Net::SSH::Any->new($hostname, user => $username, password => $password);
$ssh->error and die $ssh->error;
while ($start_date <= $end_date)
{
# Get date format
say $start_date->strftime("%d-%b-%Y");
$target_date = $start_date->strftime("%d-%b-%Y");
# convert to uppercase for the month
$target_date = uc $target_date;
# forming right SQL message
$cmd = "perl getSQLdata.pl \"SELECT \\\"Project\\\" FROM \\\"Result\\\" where to_char(to_timestamp(\\\"Start_Time\\\",\'MM/DD/RRRR HH:MI:SS AM\'),\'DD-MON-RRRR\') = \'".$target_date."\'\"";
print $cmd;
# Get SQL data
$output = $ssh->capture($cmd);
# print output
print $output."\n";
# increment a day
$start_date->add(days => 1);
}
exit 1;
http://stackoverflow.com/questions/19724688/perl-loop-through-months-in-a-specified-range
http://stackoverflow.com/questions/6622818/what-is-the-optimal-way-to-loop-between-two-dates-in-perl
# The Perl script below is trying to loop each day in a range of dates and perform SQL date query
#!/usr/bin/perl -w
use strict;
use Net::SSH::Any;
use DateTime;
use feature 'say';
my $hostname = "10.x.x.x";
my $username = "USER";
my $password = "PASS";
my $cmd = "";
my $output = "";
my $target_date = "";
my $start_date = DateTime->new(year => 2015, month => 1, day => 1);
my $end_date = DateTime->new(year=>2015, month => 7, day => 1);
my $ssh = Net::SSH::Any->new($hostname, user => $username, password => $password);
$ssh->error and die $ssh->error;
while ($start_date <= $end_date)
{
# Get date format
say $start_date->strftime("%d-%b-%Y");
$target_date = $start_date->strftime("%d-%b-%Y");
# convert to uppercase for the month
$target_date = uc $target_date;
# forming right SQL message
$cmd = "perl getSQLdata.pl \"SELECT \\\"Project\\\" FROM \\\"Result\\\" where to_char(to_timestamp(\\\"Start_Time\\\",\'MM/DD/RRRR HH:MI:SS AM\'),\'DD-MON-RRRR\') = \'".$target_date."\'\"";
print $cmd;
# Get SQL data
$output = $ssh->capture($cmd);
# print output
print $output."\n";
# increment a day
$start_date->add(days => 1);
}
exit 1;
Perl SQL example
http://www.dba-oracle.com/t_dbi_perl_sql_execution.htm
# HERE is the script that accept SQL command and get return from Oracle DB
#!/usr/bin/perl
# include oracle driver folder
BEGIN {
$ENV{ORACLE_HOME} = "/home/cybertech/app/cybertech/product/12.1.0/client_1";
$ENV{LD_LIBRARY_PATH} = "/home/cybertech/app/cybertech/product/12.1.0/client_1";
}
use lib Bundle;
use Bundle::DBI;
use DBI;
use strict;
use POSIX qw(strftime);
if ($#ARGV > 1)
{
print "\nUsage: perl getSQLdata.pl \"[SQL statement]\"\n\n\Example: perl getSQLdata.pl \"select * from tablename\"";
exit -1;
}
my $now_string = strftime "%Y%b%e_%H%M%S", localtime;
my $script_log= "SQL_log_$now_string.log";
my @sqlReturn = ();
chomp($ARGV[0]);
my $temp = "";
# Perform Oracle connection
my $dbh = DBI->connect('DBI:Oracle:host=HOSTNAME;sid=SIDNAME;port=1521', 'USERNAME', 'PASS')
or die "\n\nCouldn't connect to database: " . DBI->errstr;
# Forming SQL query
my $SQL_CMD = join("",@ARGV);
my $sth = $dbh->prepare($SQL_CMD)
or die "\n\nCouldn't prepare statement: " . $dbh->errstr;
# Run SQL command
$sth->execute() || try_again();
# open file handler
open (WF, ">$script_log") || die "\n$!\n";
# Loop each row of data
while(my @row = $sth->fetchrow_array())
{
@sqlReturn = ();
# display each column
foreach(@row)
{
$_ = "\t" if !defined($_);
#print "$_\t";
print WF "$_".",";
push (@sqlReturn, $_.",");
}
print @sqlReturn;
print "\n";
print WF "\n";
$temp = join("",@sqlReturn);
$temp = "";
}
END
{ $dbh->disconnect if defined($dbh); }
exit 1;
# HERE is the script that accept SQL command and get return from Oracle DB
#!/usr/bin/perl
# include oracle driver folder
BEGIN {
$ENV{ORACLE_HOME} = "/home/cybertech/app/cybertech/product/12.1.0/client_1";
$ENV{LD_LIBRARY_PATH} = "/home/cybertech/app/cybertech/product/12.1.0/client_1";
}
use lib Bundle;
use Bundle::DBI;
use DBI;
use strict;
use POSIX qw(strftime);
if ($#ARGV > 1)
{
print "\nUsage: perl getSQLdata.pl \"[SQL statement]\"\n\n\Example: perl getSQLdata.pl \"select * from tablename\"";
exit -1;
}
my $now_string = strftime "%Y%b%e_%H%M%S", localtime;
my $script_log= "SQL_log_$now_string.log";
my @sqlReturn = ();
chomp($ARGV[0]);
my $temp = "";
# Perform Oracle connection
my $dbh = DBI->connect('DBI:Oracle:host=HOSTNAME;sid=SIDNAME;port=1521', 'USERNAME', 'PASS')
or die "\n\nCouldn't connect to database: " . DBI->errstr;
# Forming SQL query
my $SQL_CMD = join("",@ARGV);
my $sth = $dbh->prepare($SQL_CMD)
or die "\n\nCouldn't prepare statement: " . $dbh->errstr;
# Run SQL command
$sth->execute() || try_again();
# open file handler
open (WF, ">$script_log") || die "\n$!\n";
# Loop each row of data
while(my @row = $sth->fetchrow_array())
{
@sqlReturn = ();
# display each column
foreach(@row)
{
$_ = "\t" if !defined($_);
#print "$_\t";
print WF "$_".",";
push (@sqlReturn, $_.",");
}
print @sqlReturn;
print "\n";
print WF "\n";
$temp = join("",@sqlReturn);
$temp = "";
}
END
{ $dbh->disconnect if defined($dbh); }
exit 1;
Thursday, June 25, 2015
Why SCTP in Linux Kernel ?
Well, everyone is familiar with TCP and UDP, why still need SCTP?
SCTP provided new features as well as existed features in TCP.
Core Features of SCTP:
[1] Message Oriented
[2] Multihoming
[3] Streams
Besides that SCTP have features same as TCP:
[1] Congestion Control
[2] Selective ACK
[3] Message Fragmentation
[4] Bundling
When we need SCTP?
Let's consider a "Network Application" which operates by exchanging simultaneously, short, similar sequences of data continuously, such as client-server database application.
What will be the traffic condition for this "Network Application"?
Resource from: http://old.lwn.net/2001/features/OLS/pdf/pdf/sctp.pdf
SCTP provided new features as well as existed features in TCP.
Core Features of SCTP:
[1] Message Oriented
[2] Multihoming
[3] Streams
Besides that SCTP have features same as TCP:
[1] Congestion Control
[2] Selective ACK
[3] Message Fragmentation
[4] Bundling
When we need SCTP?
Let's consider a "Network Application" which operates by exchanging simultaneously, short, similar sequences of data continuously, such as client-server database application.
What will be the traffic condition for this "Network Application"?
Resource from: http://old.lwn.net/2001/features/OLS/pdf/pdf/sctp.pdf
SETUP CMM debug flags for 4.x, 5.x, and 6.x firmware
# Edit /etc/debug.cfg file to include data below to turn on debug
flags:
FRU_DEBUG = 1
EKEY_DEBUG = 1
REA_DEBUG = 1
IPMB_DEBUG = 1
FAILOVER_DEBUG = 1
SYNC_DEBUG = 1
FRU_DEBUG = 1
EKEY_DEBUG = 1
REA_DEBUG = 1
IPMB_DEBUG = 1
FAILOVER_DEBUG = 1
SYNC_DEBUG = 1
Julesburg software pre and post script execution
Julesburg software pre and post script execution:
By default, Julesburg software is preset with
/etc/cmm/scripts/pre_cmm_startup script to execute commands for CMM initial
start up.
Besides the default script, there are 3 more script that can be preloaded
during WW/CMM operation to handle automated scripting or commands
execution.
Default:
/etc/cmm/scripts/pre_cmm_startup
Others:
/etc/cmm/scripts/post_cmm_startup
/etc/cmm/scripts/pre_cmm_shutdown
/etc/cmm/scripts/post_cmm_shutdown
/etc/cmm/scripts/pre_cmm_shutdown
/etc/cmm/scripts/post_cmm_shutdown
Each of the scripts above executed at different time of CMM
operations.
pre_cmm_startup: Executed once WindRiver Linux has boot up
but before Julesburg is brought up.
post_cmm_startup: Executed when Julesburg/CMM just boot up
or initialized and running.
pre_cmm_shutdown: Executed when Julesburg/CMM received
terminate CMM/Julesburg signal but CMM not yet stop.
post_cmm_shutdown: Executed when Julesburg/CMM received
terminate CMM/Julesburg signal and after CMM stop.
These scripts are useful when customers or engineers want to execute
scripts/commands/creating logs and etc at the 4 time phase explained
above.
UCM ClearCase View creation and removal (Linux/UNIX view)
This document: ClearCaseUCM_howto_createview.docx
One time step for Linux like
utilities in Windows 7
1. Unzip “custom-path.zip” to
C:\
2. Goto My Computer > Properties
3. Select “Advanced system settings”
4. Select “Environment Variables”
5. Edit user variable “Path”, include the
“C:\custom-path;”
6. Click ok, ok.
7. To take user environment variable effective, just
logout and log in again.
STEPS to create UCM ClearCase view
and remove UCM ClearCase view
1. Identify what Project and Stream you going to work on
using “ClearCase Project Explorer”.
2. Goto C:\custom-path-radisys and click
“Create_UCM_Linux_view.bat” (you create this as shortcut to your desktop or any
other place)
3. After created the view in Linux/UNIX, the screen below
pop up to synchronize it to Windows ClearCase. (to allow access/work on
Linux/UNIX view from Windows)
4. Select the view has just created and click
“Import”.
5. Warning below pop up, just click
“ok”
7. After finish import, click “Close” and view is created
in Linux and visible in both Windows and Linux now.
8. To confirm UCM view created to correct stream, goto
“ClearCase Project Explorer” and select the stream’s
properties.
9. All view attached to the stream will be listed in
“view” tab.
HOW to remove UCM
view:
1. Login 10.111.2.38 or mycc01 server
2. List your view name, “cleartool lsview | grep
”
3. To remove, “cleartool rmview –tag ”
and it is done.
Upgrade old CDM to new CDM using latest WW/JB firmware
This guide is to help on how to flash CDM(before
8.1.1.01) when using WW/JB after 8.1.1.01.
Issue/problem:
After WW boot up in chassis (6014/NEC), it not able goto Act/Stdby and at
the same time rsys-ipmitool not able to flash/read CDM (error message device ID
not found)
Solution:
1. Stop CMM (command: "cmm stop")
2. Manually input / tell IPMC what chassis are you using now with command
below:
i) NEC (CMM will reboot after execute command below)
rsys-ipmitool raw 0x2e 0xc0 0xf1 0x10 0 5
ii) 6014/6016
rsys-ipmitool raw 0x2e 0xc0 0xf1 0x10 0 6
3. Once WW rebooted, login again and stop the cmm.
4. In CMM1, Verify you can read the CDM now by executing command
rsys-ipmitool -t 0x20 -m 0x10 fru read 1 FILENAME.bin
5. If can read, then proceed with flashing new CDM in CMM1
rsys-ipmitool -t 0x20 -m 0x10 fru write 1 NEWCDM.bin
6. Reboot/power cycle whole chassis and wait the WW/JB boot up and go into
Act/Stdby state.
Timnath: downgrade 7.x (JB) to 5.x (Timnath) on Colorado Springs (CMM hardware)
Downgrading from 7.x JulesBurg to 5.x (Timnath) CAN NOT use "cmmset -d update" CLI
command.
The steps below need to be followed in order to downgrade:
1. copy \\10.111.2.37\root\tftpboot\ColoradoSprings\downgradeFrom7.x to
home folder and rename to downgrade. (there is character limitation on cmmset -d
update)
2. Transfer (SCP/FTP) into CMM /usr/local/data/temp
3. Downgrade the CMM with command below:
cmmset -d update -v "/usr/local/data/temp/___CMM_5.2.8.75_DOWNGRADE__
_ force"
_ force"
Configure NIS server
1. Login as root
2. in terminal, type "authconfig"
3. select NIS and click [NEXT]
4. Domain=cybertech
5. Server=cybertech01.cybertech.com
6. ypwhich to verify machine is bound to cybertech01
7. ypcat passwd | more to verify machine is bound and login accounts.
Just run "ypwhich" command after authconfig to verify that you are bound to
"cybertech01".
I also do a "ypcat passwd| more" this will verify that you are bound AND youcan see login accounts.
I also do a "ypcat passwd| more" this will verify that you are bound AND youcan see login accounts.
Wednesday, June 24, 2015
RHEL set hardware clock then set system clock
http://www.hypexr.org/linux_date_time_help.php
[cybertech@cybertech01 ~]$ date
Wed Jun 24 23:58:33 MYT 2015
[cybertech@cybertech01 ~]$ sudo hwclock --set --date="06/24/2015 16:00:00"
[cybertech@cybertech01 ~]$ date
Wed Jun 24 23:59:50 MYT 2015
[cybertech@cybertech01 ~]$ sudo hwclock --show
Wed 24 Jun 2015 04:00:29 PM MYT -0.515954 seconds
[cybertech@cybertech01 ~]$ date
Thu Jun 25 00:00:22 MYT 2015
[cybertech@cybertech01 ~]$ sudo hwclock --hctosys
[cybertech@cybertech01 ~]$ date
Wed Jun 24 16:01:15 MYT 2015
[cybertech@cybertech01 ~]$ date
Wed Jun 24 23:58:33 MYT 2015
[cybertech@cybertech01 ~]$ sudo hwclock --set --date="06/24/2015 16:00:00"
[cybertech@cybertech01 ~]$ date
Wed Jun 24 23:59:50 MYT 2015
[cybertech@cybertech01 ~]$ sudo hwclock --show
Wed 24 Jun 2015 04:00:29 PM MYT -0.515954 seconds
[cybertech@cybertech01 ~]$ date
Thu Jun 25 00:00:22 MYT 2015
[cybertech@cybertech01 ~]$ sudo hwclock --hctosys
[cybertech@cybertech01 ~]$ date
Wed Jun 24 16:01:15 MYT 2015
Perl SSH by example
# Module INSTALLATION
In windows command prompt, to install Net::SSH::Any Perl module (Strawberry Perl)
perl -MCPAN -e "install Net::SSH::Any"
# How to create SSH perl script, pass through single command and get the output:
Still supported example:
http://stackoverflow.com/questions/13457178/perlnetssh2-how-to-keep-the-ssh-connection-while-executing-remote-command
#!/usr/bin/perl -w
use strict;
use Net::SSH::Any;
my $hostname = "hostname";
my $username = "username";
my $password = "password";
my $cmd = "@ARGV";
my $ssh = Net::SSH::Any->new($hostname, user => $username, password => $password);
$ssh->error and die $ssh->error;
my $output = $ssh->capture($cmd);
print $output."\n\n";
exit 1;
Old - might not able to get the full perl module installed as it has no longer supported
http://stackoverflow.com/questions/2848725/how-can-i-ssh-inside-a-perl-script
http://www.perlhowto.com/execute_commands_on_remote_machines_using_ssh
In windows command prompt, to install Net::SSH::Any Perl module (Strawberry Perl)
perl -MCPAN -e "install Net::SSH::Any"
# How to create SSH perl script, pass through single command and get the output:
Still supported example:
http://stackoverflow.com/questions/13457178/perlnetssh2-how-to-keep-the-ssh-connection-while-executing-remote-command
#!/usr/bin/perl -w
use strict;
use Net::SSH::Any;
my $hostname = "hostname";
my $username = "username";
my $password = "password";
my $cmd = "@ARGV";
my $ssh = Net::SSH::Any->new($hostname, user => $username, password => $password);
$ssh->error and die $ssh->error;
my $output = $ssh->capture($cmd);
print $output."\n\n";
exit 1;
Old - might not able to get the full perl module installed as it has no longer supported
http://stackoverflow.com/questions/2848725/how-can-i-ssh-inside-a-perl-script
http://www.perlhowto.com/execute_commands_on_remote_machines_using_ssh
$ ssh user@host "command" > output.file
#!/usr/bin/perl -w
use strict;
use lib qw("/path/to/module/");
use Net::SSH::Perl;
my $hostname = "hostname";
my $username = "username";
my $password = "password";
my $cmd = shift;
my $ssh = Net::SSH::Perl->new("$hostname", debug=>0);
$ssh->login("$username","$password");
my ($stdout,$stderr,$exit) = $ssh->cmd("$cmd");
print $stdout;
Labels:
perl,
Perl ssh example,
Perl ssh script example,
SSH,
ssh Perl
Tuesday, June 23, 2015
Install Perl Module online (live install)
To ease Perl modules installation, instruction can be used to install Perl module directly from CPAN.
LINUX:
sudo perl -MCPAN -e 'install Net::SSH'
sudo perl -MCPAN -e 'install DBD::Oracle'
...
C:\Strawberry\perl\bin\perl.exe -MCPAN -e "install Net::Google::Spreadsheets"
LINUX:
sudo perl -MCPAN -e 'install Net::SSH'
sudo perl -MCPAN -e 'install DBD::Oracle'
...
Windows:
C:\Strawberry\perl\bin\perl.exe -MCPAN -e "install Spreadsheet::ParseExcel"
C:\Strawberry\perl\bin\perl.exe -MCPAN -e "install Spreadsheet::WriteExcel"
C:\Strawberry\perl\bin\perl.exe -MCPAN -e "install Spreadsheet::ParseExcel"
C:\Strawberry\perl\bin\perl.exe -MCPAN -e "install Spreadsheet::WriteExcel"
C:\Strawberry\perl\bin\perl.exe -MCPAN -e "install Net::Google::Spreadsheets"
Wednesday, June 17, 2015
Installing RHEL 6.5 into UEFI bootable Dell R320 server
Objective: Install RHEL into R320 server with 64 bits image
Problem: After RHEL installation, RHEL unable to boot up and failed to find boot image
Solution:
- During the partition creation, /boot/efi partition has been left out.
- Therefore reinstall with /boot/efi partition solved this un-bootable issue.
Problem: After RHEL installation, RHEL unable to boot up and failed to find boot image
Solution:
- During the partition creation, /boot/efi partition has been left out.
- Therefore reinstall with /boot/efi partition solved this un-bootable issue.
Oracle.pm Perl module installation
Objective: To able write execute perl script to access to Oracle database
Problems:
Error messages when executing perl script to connect Oracle database:
- Can't locate object method "connect" via package "DBI" (even you have copied the oracle.pm into the DBD folder)
Solutions:
- Need to identify the RHEL / Linux OS you have executed has the /usr/local/lib64/perl5/DBD/Oracle.pm
- If the Oracle.pm is not there, then you need to follow the steps below:
i) Install Oracle client into your RHEL machine
- For RHEL 6.5, is advised to install Oracle client 12.0.2 which compatible with this distro version.
- Download link http://www.oracle.com/technetwork/database/enterprise-edition/downloads/database12c-linux-download-1959253.html
- Choose the Oracle Database 12c Release 1 Client (12.1.0.1.0) for Linux x86-64 (my RHEL 6.5 is running on 64 bits)
- Extract and execute the client installer "./runInstaller"
- If there are dependencies missing, try use "yum search xxxx" for the exact packages. Then to install the packages "yum install YYYYY"
- Redo until all required packages are installed.
ii) Before you can compiled and create the right Oracle.pm, here are some dependencies that needed from Oracle website:
- http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
-- oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-odbc-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-tools-12.1.0.2.0-1.x86_64.rpm
- To install them type: "sudo rpm -ivh oracle-instantclient12.1-tools-12.1.0.2.0-1.x86_64.rpm"
-- If these packages are not installed, then you will see error messages during compilation as below:
iii) Finally can start to compile by create a script named test.sh, additional 2 lines on top is required to set the environment right before compilation to produce the Oracle.pm module
[kyfoo@hostname~]$ cat test.sh
export LD_LIBRARY_PATH=/home/kyfoo/app/kyfoo/product/12.1.0/client_1
export ORACLE_HOME-=/home/kyfoo/app/kyfoo/product/12.1.0/client_1
perl -MCPAN -e 'install DBD::Oracle'
Problems:
Error messages when executing perl script to connect Oracle database:
- Can't locate object method "connect" via package "DBI" (even you have copied the oracle.pm into the DBD folder)
Solutions:
- Need to identify the RHEL / Linux OS you have executed has the /usr/local/lib64/perl5/DBD/Oracle.pm
- If the Oracle.pm is not there, then you need to follow the steps below:
i) Install Oracle client into your RHEL machine
- For RHEL 6.5, is advised to install Oracle client 12.0.2 which compatible with this distro version.
- Download link http://www.oracle.com/technetwork/database/enterprise-edition/downloads/database12c-linux-download-1959253.html
- Choose the Oracle Database 12c Release 1 Client (12.1.0.1.0) for Linux x86-64 (my RHEL 6.5 is running on 64 bits)
- Extract and execute the client installer "./runInstaller"
- If there are dependencies missing, try use "yum search xxxx" for the exact packages. Then to install the packages "yum install YYYYY"
- Redo until all required packages are installed.
ii) Before you can compiled and create the right Oracle.pm, here are some dependencies that needed from Oracle website:
- http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
-- oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-odbc-12.1.0.2.0-1.x86_64.rpm
-- oracle-instantclient12.1-tools-12.1.0.2.0-1.x86_64.rpm
- To install them type: "sudo rpm -ivh oracle-instantclient12.1-tools-12.1.0.2.0-1.x86_64.rpm"
-- If these packages are not installed, then you will see error messages during compilation as below:
cp mk.pm blib/arch/auto/DBD/Oracle/mk.pm/usr/bin/perl -p -e "s/~DRIVER~/Oracle/g" /usr/lib64/perl5/auto/DBI/Driver.xst >/usr/bin/perl /usr/share/perl5/ExtUtils/xsubpp -typemap /usr/share/perl5/ExtUtigcc -c -I/usr/lib64/perl5/auto/DBI -D_REENTRANT -D_GNU_SOURCE -fno-strict-alias_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 SUPPORT -DORA_OCI_VERSION=\"12.1.0.2\" -DORA_OCI_102 -DORA_OCI_112 Oracle.cIn file included from Oracle.xs:1:Oracle.h:37:17: error: oci.h: No such file or directoryOracle.h:38:22: error: oratypes.h: No such file or directoryOracle.h:39:20: error: ocidfn.h: No such file or directoryOracle.h:40:18: error: orid.h: No such file or directoryOracle.h:41:17: error: ori.h: No such file or directoryIn file included from Oracle.h:52, from Oracle.xs:1:dbdimp.h:23: error: expected specifier-qualifier-list before ‘OCIEnv’dbdimp.h:41: error: expected specifier-qualifier-list before ‘OCIEnv’dbdimp.h:93: error: expected specifier-qualifier-list before ‘OCIEnv’dbdimp.h:159: error: expected specifier-qualifier-list before ‘ub4’In file included from Oracle.h:52, from Oracle.xs:1:dbdimp.h:173: error: expected specifier-qualifier-list before ‘text’dbdimp.h:199: error: expected specifier-qualifier-list before ‘OCIParam’dbdimp.h:246: error: expected specifier-qualifier-list before ‘sword’dbdimp.h:294: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘chdbdimp.h:295: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ncdbdimp.h:296: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘usdbdimp.h:297: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘utdbdimp.h:298: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘aldbdimp.h:299: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘aldbdimp.h:321: error: expected declaration specifiers or ‘...’ before ‘OCILobLocadbdimp.h:323: error: expected ‘)’ before ‘bufl’dbdimp.h:324: error: expected ‘)’ before ‘piece_size’dbdimp.h:336: error: expected declaration specifiers or ‘...’ before ‘OCIError’dbdimp.h:336: error: expected declaration specifiers or ‘...’ before ‘sword’dbdimp.h:336: error: expected declaration specifiers or ‘...’ before ‘sb4’dbdimp.h:341: error: expected ‘)’ before ‘status’dbdimp.h:342: error: expected ‘)’ before ‘mode’dbdimp.h:343: error: expected ‘)’ before ‘options’dbdimp.h:344: error: expected ‘)’ before ‘options’dbdimp.h:345: error: expected ‘)’ before ‘hdtype’dbdimp.h:346: error: expected ‘)’ before ‘attr’dbdimp.h:347: error: expected ‘)’ before ‘mode’dbdimp.h:350: error: expected ‘)’ before ‘attr’dbdimp.h:358: error: expected declaration specifiers or ‘...’ before ‘ub4’dbdimp.h:367: error: expected declaration specifiers or ‘...’ before ‘ub4’dbdimp.h:368: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ordbdimp.h:377: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dbdbdimp.h:379: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘dbdbdimp.h:382: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘prdbdimp.h:391: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ordbdimp.h:392: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘reIn file included from Oracle.xs:1:Oracle.h:92: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘oraOracle.h:94: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘oraOracle.h:131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘OCOracle.xs: In function ‘XS_DBD__Oracle__st_ora_stmt_type’:Oracle.xs:129: error: ‘imp_sth_t’ has no member named ‘stmt_type’Oracle.xs: In function ‘XS_DBD__Oracle__st_ora_stmt_type_name’:Oracle.xs:138: error: ‘imp_sth_t’ has no member named ‘stmt_type’
iii) Finally can start to compile by create a script named test.sh, additional 2 lines on top is required to set the environment right before compilation to produce the Oracle.pm module
[kyfoo@hostname~]$ cat test.sh
export LD_LIBRARY_PATH=/home/kyfoo/app/kyfoo/product/12.1.0/client_1
export ORACLE_HOME-=/home/kyfoo/app/kyfoo/product/12.1.0/client_1
perl -MCPAN -e 'install DBD::Oracle'
iv) Verify Oracle.pm is ready, it will be existed at /usr/local/lib64/perl5/DBD/Oracle.pm
- Now you can write the perl script to test the connectivity or download any example to try it.
Subscribe to:
Posts (Atom)