2018年8月21日 星期二

ssh and scp in the python

#!/usr/bin/env python
import os
import paramiko

from scp import SCPClient
from paramiko import SSHClient

def main():

    ssh = SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(hostname='10.99.241.36', port=22, username='root', password='0penBmc')
    stdin, stdout, stderr = ssh.exec_command('df')
    print(stdout.read().decode())
    ssh.close()

    ssha = SSHClient()
    ssha.load_system_host_keys()
    ssha.connect(hostname='10.99.241.36', port=22, username='root', password='0penBmc')
    with SCPClient(ssha.get_transport()) as scp:
        scp.put('tiogapass-20180822055635.all.tar', '/tiogapass-20180822055635.all.tar')
    scp.close()
    ssha.close()

    print 'Completed!'

if __name__ == "__main__":
    main()

2016年10月12日 星期三

2016年10月11日 星期二

Install 遠端桌面 for ubuntu.

sudo apt-get install xrdp
sudo apt-get install vnc4server
sudo apt-get install xubuntu-desktop
echo "xfce4-session" >~/.xsession
sudo service xrdp restart

2016年1月27日 星期三

SOL via ipmiutil

You can use the below command to verify SOL function.

ipmiutil sol -a -N 172.16.1.41 -U admin -P admin -V 4 -i host.sh  -o tmp.log

2016年1月5日 星期二

Compute the executing time in the code

struct timeval tv , tv2 ;
unsigned long      start_utime , end_utime;
float      time_period;
...
...

2015年10月16日 星期五

Tera term note

1. Reset the BMC and the system by executing the macro:

while 1
wait "C:\>"
pause 10

2015年10月14日 星期三

kermit note

In the /root/.kermrc, add the below lines

set line /dev/ttyS0
set speed 38400
set carrier-watch off
set handshake none
set flow-control none

2015年10月1日 星期四

2015年9月21日 星期一

Syslog under Ubuntu

vi /etc/rsyslog.conf

#
# Include all config files in /etc/rsyslog.d/
#
$IncludeConfig /etc/rsyslog.d/*.conf

2015年7月29日 星期三

How to check the EEPROM in Intel X520.

1. Go to IBL to download the latest Intel® Network Connections Tools

2. Boot to DOS, then execute lanconf.exe in the dos/svtools/

3. Select Flash/EEPROM, and choice Raw EEPROM.

2015年7月1日 星期三

Enable UART4 in AST2500

mw 1e6e2000 1688a8a8

mw 1e6e200c e1c47e80

mw 1e78f00c 93

mw 1e78f00c 27 //Baudrate 38400 (divisor =13x3=39=27h)

mw 1e78f00c 13

mw 1e78f000 45 //output 'D'

2015年6月2日 星期二

[Linux]HZ, jiffies and tick

HZ: total timer interrupts per second.
tick: 1/HZ, the time for each timer interrupt.
jiffies: total ticks from Linux boot.

Do something after 1 second, e.g. kernel timer
jiffies + (1 second)/ticks = jiffies + HZ


2015年5月25日 星期一

2015年5月13日 星期三

Simple Linux Socket example

I would like to send the UDP packet carries the syslog payload.

#include the below head file
sys/socket.h
linux/sockios.h
fcntl.h
netdb.h
netinet/ether.h
netpacket/packet.h
net/if.h

The note for Linux shell

1. Iterate the member in the array
declare -a array

for i in "${arrar[@]}"
do
    echo $i
done

2015年5月12日 星期二

簡易DHCP server架設

In Ubuntu,

1. Configure the server IP as 192.168.1.254

2. Configure the default inteface
vi /etc/sysconfig/dhcpd
INTERFACES="eth3"


2015年4月20日 星期一

udhcpc in the Busybox

udhcpc [-Cfbnqtvo] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]
[-p pidfile] [-r IP] [-s script] [-O dhcp-option]...

2015年4月15日 星期三

[Linux]Custom ioctl command for sockets

於network interface可定義下面的 operations

dev->open = henbin_open;
dev->stop = henbin_close;

如有需要透過sockets呼叫custom ioctl,可增加一個如下的ioctl function

2015年4月7日 星期二

Enable kcs debug for OpenIPMI driver

可以透過下列的方式打開kcs debug...
echo 7 > /sys/module/ipmi_si/parameters/kcs_debug

即可在dmesg看到kcs state, 包含兩個數字

第一個數字為driver定義的kcs state:

2015年3月16日 星期一

[Linux]Change the baudrate while uncompressing Linux.

Edit the below source file  and change the BAUD_RATE.

linux/arch/arm/include/asm/soc-ast2400/lowlevel_serial.h