PIXNET Logo登入

台灣 富捷 IT 培訓

跳到主文

富捷 IT 培訓不斷的在市場調查”人才需求”及為學員尋求”最佳工作機會”的前提下提供了一系列的教育課程;不僅著重於科技與知識上的養成,更強調科技人的邏輯思考、分析能力與創造力。由旅美學人著眼於美國教育的優點,再融合台灣教育的方式,創造出與市場上獨一無二的教學方式;所有教師均受過嚴格的測試及教育以確保客戶的權益及奇科的高教學品質,我們本著良心及高度的熱忱,希望我們的客戶不僅能學到所需的知識,更能學到書本以外的觀念及找到未來發展的方向。

部落格全站分類:數位生活

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 12月 23 週日 201217:51
  • Perl program uses parallel processes( fork() ) to manage numeric Cisco equipment/device


Cisco Perl Telnet Script:
A single process Perl program fetches Cisco routers/switches config or other info may take 2 seconds per equipment. If you have 1,000 Cisco routers/switches, it will take 2,000 seconds which will be 33+ minutes. This Perl multi-processes program will save tons of your time to gather info like around 10 seconds. Please enjoy!
1. Successful messages( scalar type ) are stored in hash of hash : $hostinfo{ “$hostname” }->{ “$cmd” }
2. Failed messages( scalar type ) are stored in hash of hash : $hosterrinfo{ “$hostname” }->{ “$cmd” }
#!/usr/bin/perl -w
# This perl script is main to be doing numeric cisco equipment management
use strict;
use IPC::Shareable;
$SIG{ 'CHLD' } = 'IGNORE';
my @hosts = ( ''host name or IP', ''host name or IP' );
my @cmds = ( 'sh geego', 'sh ver', 'sh clock', 'sh queueing', 'sh hosts' );
my $username = 'username';  # cisco telnet username
my $passwd = 'password';   # cisco telnet username
my $enable_passwd = 'enable password';
my %hostinfo = ();
my %hosterrinfo = ();
my @children = ();
my %ipcoptions = ( create => 'yes',
exclusive => 0,
mode => 0644,
destroy => 'yes' );
tie %hostinfo, 'IPC::Shareable', 'good', \%ipcoptions or die "Can't tie %hostinfo.\n";
tie %hosterrinfo, 'IPC::Shareable', 'err', \%ipcoptions or die "Can't tie %hosterrinfo\n";
foreach my $host ( @hosts )
{
my $pid = fork();
die "Can't fork.:$!\n" unless defined( $pid );
if( $pid == 0 ) # this is child process
{
print "Child process is $$\n";
get_info( $host );
exit( 0 );
}
else # This is parent process
{
print "$$ -> Process $pid is processing $host now.\n";
push( @children, $pid );
}
}
foreach ( @children )
{
#my $child_pid = waitpid( $_, 0 );
my $child_pid = wait();
print "Process $_ is done.\n";
}
sub get_info
{
use Net::Telnet::Cisco;  #Special Perl Cisco Telnet module
my ( $hostname ) = @_;
my $cisco = Net::Telnet::Cisco->new( 'Host' => $hostname,
'Errmode'=> 'return' );  #Perl Cisco Telnet Object initialization
$cisco->login( Password => "$passwd" );
$cisco->ignore_warnings;
foreach my $cmd ( @cmds )
{
my @output = $cisco->cmd( "$cmd" );
if( $cisco->errmsg() )
{
$hosterrinfo{ $hostname }->{ $cmd } = $cisco->errmsg();
}
else
{
my $out = join( "", @output );
$hostinfo{ $hostname }->{ $cmd } = $out;
}
}
}
foreach my $host ( keys %hostinfo )
{
foreach my $cmd ( keys %{$hostinfo{ $host }} )
{
print "$host => $cmd =>\n $hostinfo{ $host }->{ $cmd }\n";
}
}
(繼續閱讀...)
文章標籤

台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣(8)

  • 個人分類:技術小秘訣
▲top
  • 12月 23 週日 201217:48
  • Cisco Perl threads program to manage numeric Cisco equipments


Cisco Perl Telnet Script:
A single thread Perl program fetches Cisco routers/switches config or other info may take 2 seconds per equipment. If you have 1,000 Cisco routers/switches, it’ll take 2,000 seconds which will be 33+ mins. This Perl threads program will save tons of your time to gather info like within 10 seconds. Please enjoy!
1. Successful messages( scalar type ) are stored in hash of hash : $hostinfo{ “$hostname” }->{ “$cmd” }
2. Failed messages( scalar type ) are stored in hash of hash : $hosterrinfo{ “$hostname” }->{ “$cmd” }
#!/usr/bin/perl -w
# This perl script is main to be doing numeric cisco equipment management
use strict;
use threads;
use threads::shared;
my @hosts = ( 'host name or IP', 'host name or IP' );
my @threads = ();
# Shared data declaration
my @cmds :shared = ( 'sh geego', 'sh ver', 'sh clock', 'sh queueing', 'sh hosts' );
my $username :shared = 'username';  # cisco telnet username
my $passwd :shared = 'password';   # cisco telnet username
my $enable_passwd :shared = 'enable password';
my %hostinfo :shared = ();
my %hosterrinfo :shared = ();
foreach my $host ( @hosts )
{
$hostinfo{ "$host" } = &share( {} );
$hosterrinfo{ "$host" } = &share( {} );
push( @threads, threads->new( \&get_info, $host ) );
}
foreach ( @threads )
{
$_->join();
}
sub get_info
{
use Net::Telnet::Cisco;  #Special Perl Cisco Telnet module
my ( $hostname ) = @_;
my $cisco = Net::Telnet::Cisco->new( 'Host' => $hostname,
'Errmode'=> 'return' );  #Perl Cisco Telnet Object initialization
$cisco->login( Password => "$passwd" );
$cisco->ignore_warnings;
foreach my $cmd ( @cmds )
{
my @output = $cisco->cmd( "$cmd" );
if( $cisco->errmsg() )
{
$hosterrinfo{ $hostname }->{ $cmd } = $cisco->errmsg();
}
else
{
my $out = join( "", @output );
$hostinfo{ $hostname }->{ $cmd } = $out;
}
}
}
foreach my $host ( keys %hostinfo )
{
foreach ( keys %{$hostinfo{ $host }} )
{
print " $host => $_ => $hostinfo{ $host }->{ $_ }";
}
}
(繼續閱讀...)
文章標籤

台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣(11)

  • 個人分類:技術小秘訣
▲top
  • 12月 19 週三 201214:21
  • 奇科電腦 平行多程序( fork() )的Cisco設備的Perl程式


Cisco Perl Telnet Script:
利用telnet取得每個Cisco路由器或交換器的組態或訊息所需時間約2秒鐘,如果貴公司有1,000台Cisco設備,一般單執行緒程式恐耗時 2,000秒相當於33+分鐘,本Perl程式使用平行多程序同時對所有的Cisco設備進行存取,所需時間可能不到10秒鐘;請各位試試看。
 
1. 執行成功訊息輸出(scalar type)儲存於$hostinfo{ 主機名稱 }->{ 執行指令 }
2. 執行失敗訊息輸出(scalar type)儲存於$hosterrinfo{ 主機名稱 }->{ 執行指令 }
#!/usr/bin/perl -w
# This perl script is main to be doing numeric cisco equipment management
use strict;
use IPC::Shareable;
$SIG{ 'CHLD' } = 'IGNORE';
my @hosts = ( '主機名稱或IP定址', '主機名稱或IP定址' );
my @cmds = ( 'sh geego', 'sh ver', 'sh clock', 'sh queueing', 'sh hosts' );
my $username = '登入帳號名稱';  # cisco telnet 的帳號
my $passwd = '帳號之密碼';    # cisco telnet 的密碼
my $enable_passwd = 'enable的密碼';
my %hostinfo = ();
my %hosterrinfo = ();
my @children = ();
my %ipcoptions = ( create => 'yes',
exclusive => 0,
mode => 0644,
destroy => 'yes' );
tie %hostinfo, 'IPC::Shareable', 'good', \%ipcoptions or die "Can't tie %hostinfo.\n";
tie %hosterrinfo, 'IPC::Shareable', 'err', \%ipcoptions or die "Can't tie %hosterrinfo\n";
foreach my $host ( @hosts )
{
my $pid = fork();
die "Can't fork.:$!\n" unless defined( $pid );
if( $pid == 0 ) # this is child process
{
print "Child process is $$\n";
get_info( $host );
exit( 0 );
}
else # This is parent process
{
print "$$ -> Process $pid is processing $host now.\n";
push( @children, $pid );
}
}
foreach ( @children )
{
#my $child_pid = waitpid( $_, 0 );
my $child_pid = wait();
print "Process $_ is done.\n";
}
sub get_info
{
use Net::Telnet::Cisco;  # 特別的 Perl Cisco Telnet的模組
my ( $hostname ) = @_;
my $cisco = Net::Telnet::Cisco->new( 'Host' => $hostname,
'Errmode'=> 'return' );  # Perl Cisco Telnet的物件初始化
$cisco->login( Password => "$passwd" );
$cisco->ignore_warnings;
foreach my $cmd ( @cmds )
{
my @output = $cisco->cmd( "$cmd" );
if( $cisco->errmsg() )
{
$hosterrinfo{ $hostname }->{ $cmd } = $cisco->errmsg();
}
else
{
my $out = join( "", @output );
$hostinfo{ $hostname }->{ $cmd } = $out;
}
}
}
foreach my $host ( keys %hostinfo )
{
foreach my $cmd ( keys %{$hostinfo{ $host }} )
{
print "$host => $cmd =>\n $hostinfo{ $host }->{ $cmd }\n";
}
}
(繼續閱讀...)
文章標籤

台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣(19)

  • 個人分類:技術小秘訣
▲top
  • 12月 19 週三 201214:19
  • 奇科電腦 Perl執行緒程式用於部署大量Cisco設備的組態或收集資訊



Cisco Perl Telnet Script:


利用telnet取得每個Cisco路由器或交換器的組態或訊息所需時間約2秒鐘,如果貴公司有1,000台Cisco設備,一般單執行緒程式恐耗時 2,000秒相當於33+分鐘,本多執行緒Perl程式可同時對所有的Cisco設備進行存取,所需時間可能不到10秒鐘;請各位試試看。

 


1. 執行成功訊息輸出(scalar type)儲存於hash of hash : $hostinfo{ 主機名稱 }->{ 執行指令 }
2. 執行失敗訊息輸出(scalar type)儲存於hash of hash: $hosterrinfo{ 主機名稱 }->{ 執行指令 }


#!/usr/bin/perl -w
# This perl script is main to be doing numeric cisco equipment management
use strict;
use threads;
use threads::shared;
my @hosts = ( '主機名稱或IP', '主機名稱或IP' );
my @threads = ();
# Shared data declaration
my @cmds :shared = ( 'sh geego', 'sh ver', 'sh clock', 'sh queueing', 'sh hosts' );
my $username :shared = '登入帳號名稱';  # cisco telnet 的帳號
my $passwd :shared = '登入密碼';     # cisco telnet 的帳號
my $enable_passwd :shared = 'enable的密碼';
my %hostinfo :shared = ();
my %hosterrinfo :shared = ();
foreach my $host ( @hosts )
{
$hostinfo{ "$host" } = &share( {} );
$hosterrinfo{ "$host" } = &share( {} );
push( @threads, threads->new( \&get_info, $host ) );
}
foreach ( @threads )
{
$_->join();
}
sub get_info
{
use Net::Telnet::Cisco;  # 特別的 Perl Cisco Telnet的模組
my ( $hostname ) = @_;
my $cisco = Net::Telnet::Cisco->new( 'Host' => $hostname,
'Errmode'=> 'return' );  # Perl Cisco Telnet的物件初始化
$cisco->login( Password => "$passwd" );
$cisco->ignore_warnings;
foreach my $cmd ( @cmds )
{
my @output = $cisco->cmd( "$cmd" );
if( $cisco->errmsg() )
{
$hosterrinfo{ $hostname }->{ $cmd } = $cisco->errmsg();
}
else
{
my $out = join( "", @output );
$hostinfo{ $hostname }->{ $cmd } = $out;
}
}
}
foreach my $host ( keys %hostinfo )
{
foreach ( keys %{$hostinfo{ $host }} )
{
print " $host => $_ => $hostinfo{ $host }->{ $_ }";
}
}



(繼續閱讀...)
文章標籤

台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣(72)

  • 個人分類:技術小秘訣
▲top
  • 8月 13 週一 201213:01
  • 奇科電腦 CentOS NTP Server 架設心得

tech-tips-centos-ntp-server-1
這一陣子在研究NTP Server的架設,不過一直對NTP_Server的Stratum階層架構弄不清礎,配合指令ntpstate和ntpq -p,裡頭顯示有關stratum的資訊更是弄的亂七八糟。好不容易設計幾個實驗,終於有點弄懂了,所以作個筆記,也順便與有興趣的朋友分享。
說明如下:
在安裝了ntp的套件之後,我們到NTP_Server的設定檔「/etc/ntp.conf』下作些編輯
(繼續閱讀...)
文章標籤

台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣(21)

  • 個人分類:技術小秘訣
▲top
  • 6月 08 週五 201217:43
  • 奇科電腦 如何取消虛擬鍵盤彈出


在manifest檔案內 標籤設定「android:windowSoftInputMode="stateHidden|adjustResize」。
例如:
<activity android:windowSoftInputMode="stateHidden|adjustResize" android:name="Route" android:label="@string/route_name">

<更多技術小秘訣請看 http://www.geego.com.tw/tech_support/programming>
(繼續閱讀...)
文章標籤

台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣(10)

  • 個人分類:技術小秘訣
▲top
  • 6月 06 週三 201217:32
  • 奇科電腦 Android水平捲動方法

ScrollView適用垂直捲動
HorizontalScrollView適用水平捲動
<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/test">
<Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="120dp" android:layout_marginTop="134dp" android:text="Button" />
</RelativeLayout>
</HorizontalScrollView>
(繼續閱讀...)
文章標籤

台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣(62)

  • 個人分類:技術小秘訣
▲top
  • 4月 09 週一 201215:02
  • 奇科電腦-Perl Mail::Sendmail 傳送 utf8字元

<更多Perl相關資訊請參考以下聯結>
http://www.geego.com.tw/edm/progm_perl_programming_fundamental/index.php?v=pixnet&c=blog&k=perl&p=progm&t=programming_fundamental
當看到錯誤訊息Wide character in subroutine entry at /usr/share/perl5/Mail/Sendmail.pm line 237.
原因可能為使用perl的Mail::Sendmail模組寄送中文時會出現的問題,請使用 use Encode把內容編碼後,
再寄信時把信件表頭中加入 Content-type = 'text/plain; charset="utf-8"' 即可
程式範例:
#!/usr/bin/perl
use Mail::Sendmail;
use utf8;
use Encode;
$email = 'perl.mail::sendmail@geego.com.tw';
$course = "test course";
my $message = "這是一封用來測試perl的Mail::Sendmail模組可否成功寄送utf8字元.\n";
$message = encode( "utf8", $message );
my %mail = ( To => "$email",
From => 'GeeGo Customer Service<customers@geego.com.tw>',
'Content-type' => 'text/plain; charset="utf-8"',
Subject => "Perl’s Mail::Sendmail sending text body with utf8 encoding",
Message => "$message" );
sendmail(%mail) or die $Mail::Sendmail::error;
(繼續閱讀...)
文章標籤

台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣(143)

  • 個人分類:技術小秘訣
▲top
  • 4月 05 週四 201216:22
  • 奇科電腦-使用GRE建立site-to-site VPN tunnel

為了方便企業在不同地理區域也能共同分享各分部的資源,企業總部與分部之間可以建立VPN通道達成資源分享的目的,本篇介紹以Cisco GRE(Generic Routing Encapsulation) 的方式來建立VPN通道
文件RFC2784(http://tools.ietf.org/html/rfc2784) 定義了GRE(Generic Routing Encapsulation)的規範,是一個簡單的IP封包封裝協定,GRE通道可以讓路由器連接兩個不同的區域網路達成一種VPN的效果
     GRE tunnel
------------site A -- -- -- -- -- -- -- -- siteB-------------
   59.12.30.9   211.22.33.99
================================================
Site A configuration:
#create gre tunnel
/sbin/ip tunnel add HQ_branch mode gre remote 211.22.33.99 \
local 59.12.30.9 ttl 255 dev eth0 key 1.2.3.4
# bring up gre tunnel interface
ip link set HQ_branch up
# assign gre tunnel ip
/sbin/ip addr add 10.1.255.1/32 peer 10.2.255.1/32 dev HQ_Branch
ifconfig HQ_Branch multicast
================================================
Site B configuration:
# add gre tunnel to hq
/sbin/ip tunnel add Branch_HQ mode gre remote 59.12.30.9 \
local 211.22.33.99 ttl 255 dev eth0 key 1.2.3.4
# bring up gre tunnel interface
/sbin/ip link set Branch_HQ up
# assign ip to gre tunnel
/sbin/ip addr add 10.2.255.1/32 peer 10.1.255.1/32 dev Branch_HQ
ifconfig Branch_HQ multicast
=================================================
(繼續閱讀...)
文章標籤

台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣(152)

  • 個人分類:技術小秘訣
▲top
  • 11月 17 週四 201114:25
  • 技術小秘訣: Buffer Overflow 教學(一)

What is a Stack
Stack 是一個抽象性的資料類型,普遍的用於電腦科學的領域中;放置於 Stack 中的物件有一個特性,最後一個被放進去的物件就是第一個要移開的物件,像是我們在一個桶子裡面放東西,最先放進去的將是最後被拿出來的;這種特性通常被稱為 Last In, First Out - LIFO。
Stack 定義了好幾種的操作模式;兩個最重要的手續為:PUSH 及 POP,PUSH 把物件放進 Stack 中,POP 則把最上面的物件移開。
Why do we use a stack
現代的電腦在設計的時候就已經考慮到高階電腦語言的使用了;建構高階電腦語言最重要的技巧就是提供 procedure 或是 function,從一個角度來看,一個 procedure呼叫就如 jump 一般改變了控制的流程(flow of control),但是不像 jump 的地方是:當 procedure 呼叫結束他的工作後,一個 function 把控制權還給statement 或是接下來的 instruction,這種高階的抽象性的運作方式必須藉助 stack 的幫忙才能得以實行。
The stack region
一個 stack 就是一個在記憶體內,連續性並相連的資料;一個名為 SP(stack pointer)的 register 指到 stack 最頂端位址,stack 的最底端是一個固定的位址;stack 的大小是由作業系統的核心動態的調整;而 CPU 則負責 PUSH 及 POP 的運作。
stack 是由一些邏輯的 stack frame 所組成,當呼叫一個 function 就會 push stack frame,當執行結果回傳後就 poped;一個 stack frame 包含了:
(繼續閱讀...)
文章標籤

台灣 富捷IT培訓 發表在 痞客邦 留言(0) 人氣(259)

  • 個人分類:技術小秘訣
▲top
12...5»

歡迎加入奇科Facebook

歡迎加入奇科Plurk

文章分類

toggle 奇科技術文件 (2)
  • 技術文件 (6)
  • 技術小秘訣 (43)
toggle 奇科課程介紹 (3)
  • 視頻教學 (54)
  • 精選熱門課程 (8)
  • 課程資訊 (18)
toggle 最新新聞 / 雜誌發表 (2)
  • 新聞快訊 (58)
  • 雜誌專欄 (3)
  • 好文分享 (1)
  • 奇科課程說明會 (3)
  • 奇科電腦 課程結業 (49)
  • 奇科學員作品分享 (8)
  • 學員經驗分享 (45)
  • 分享 (12)
  • 熱門職缺 (20)
  • 未分類文章 (1)

最新文章

  • IT領域職涯與課程說明會
  • 免費課程開跑囉!有效率地撰寫CSS - Sass語法簡介
  • 光鮮亮麗的登台,但事實是這樣嗎? - 破解『達內』蘊含的陷阱
  • 免費職涯講座來囉~
  • 2017自我提升講座第一彈!
  • 給入門者的話 - 如何選擇電腦補習班
  • 沒想到,學校沒教的技能,小兵立大功!
  • 奇科電腦_政府補助『讚』聲不斷!12萬挺你站穩專業、掌握就業
  • 20130225_Linux LPIC-1課程結訓照(南風)
  • 20130519_CCNP-TSHOOT課程結訓照(Paul)

熱門文章

  • (304)光鮮亮麗的登台,但事實是這樣嗎? - 破解『達內』蘊含的陷阱
  • (146)CHINA FINANCE NET:全球最年輕的CCIE(16歲)在中國
  • (86)奇科學員經驗分享: 蕭碩淵 / 在Java課程中,奇科的遠端教學讓我體驗到了不同於一般補習班的教學服務
  • (20)奇科學員經驗分享 : 李柏炫 / 選擇奇科(Android/LPIC-1/Lab)可以縮短很多學習時;選擇適合自己的老師與花時間練習,就可以往成功的方向靠近一點
  • (17)互聯網周刊:Sun的消失和Oracle的猜想
  • (14)奇科電腦在竹科廣播(IC之音)囉!

最新留言

  • [18/11/17] 劉宥村 於文章「IT領域職涯與課程說明會...」留言:
    在上課前的引導真的很貼心,而且我喜歡可以多次複習,彈性上課,...
  • [10/09/02] alfredop71 於文章「LPI原廠考試券超級大優惠 ...」留言:
    現在有一套網路創業系統能幫助你實現這個夢想,或是點左邊大頭...

誰來我家

參觀人氣

  • 本日人氣:
  • 累積人氣: