어쩌면 당연한걸지도 모르겠지만..
리눅스와 윈도우의 개행은 CR+LF / LF로 차이가 크다.

vi에서 보면
CR+LF는 ^M이 붙는데,
이로 인해서 쉘에서 인식을 제대로 못하고
실행을 못하는 문제가 생긴다.


bash에서는 문제가 없었던거 같은데.. 흐음..
아무튼 busybox에서 사용하는 ash의 경우에는 CR+LF의 경우에는
제대로 안되니 반드시 확인을 해야한다.


(이걸로 일주일 공쳤네 ㄱ-)
Posted by 구차니
제목이랑은 조금 심하게 다르지만..

busybox-1.10.1/networking/ping.c 의 소스를 보면
enum {
    DEFDATALEN = 56,
    MAXIPLEN = 60,
    MAXICMPLEN = 76,
    MAXPACKET = 65468,
    MAX_DUP_CHK = (8 * 128),
    MAXWAIT = 10,
    PINGINTERVAL = 1, /* 1 second */
};

라는 부분에 timeout 10초와 핑간격 1초가 정의되어 있다.
어짜피 alarm() 함수가 integer 만 받아서 소수점은 무리이므로
ping -c 를 이용하여 빠르게 핑 테스트는 힘들듯 하다.

다른 방법으로 접근을 하자면,
ping -c 1 ... ; ping -c 1 ...
이런식의 명령행으로 할 경우 1초 간격없이 빠르게 핑을 연속으로 보낼 수 있다.
Posted by 구차니
프로그램 사용2009. 8. 3. 19:18
머.. libjpeg가 그랬듯이 libpng도 별 건 없다.

$ more INSTALL
Installing libpng version 1.2.38 - July 16, 2009

On Unix/Linux and similar systems, you can simply type
    ./configure [--prefix=/path]
    make check
    make install
and ignore the rest of this document.

$ ./configure --host=sh4-linux
configure: WARNING: If you wanted to set the --build type, don't use --host.
    If a cross compiler is detected then cross compile mode will be used.
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for sh4-linux-strip... sh4-linux-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking for sh4-linux-gcc... sh4-linux-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... yes
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether sh4-linux-gcc accepts -g... yes
checking for sh4-linux-gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of sh4-linux-gcc... gcc3
checking build system type... i686-pc-linux-gnu
checking host system type... sh4-unknown-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by sh4-linux-gcc... /opt/STM/STLinux-2.2/devkit/sh4/sh4-linux/bin/ld
checking if the linker (/opt/STM/STLinux-2.2/devkit/sh4/sh4-linux/bin/ld) is GNU ld... yes
checking how to run the C preprocessor... sh4-linux-gcc -E
checking for sh4-linux-sed... /bin/sed
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for BSD- or MS-compatible name lister (nm)... /opt/STM/STLinux-2.2/devkit/sh4/bin/sh4-linux-nm -B
checking the name lister (/opt/STM/STLinux-2.2/devkit/sh4/bin/sh4-linux-nm -B) interface... BSD nm
checking the maximum length of command line arguments... 98304
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /opt/STM/STLinux-2.2/devkit/sh4/sh4-linux/bin/ld option to reload object files... -r
checking for sh4-linux-objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for sh4-linux-ar... sh4-linux-ar
checking for sh4-linux-strip... (cached) sh4-linux-strip
checking for sh4-linux-ranlib... sh4-linux-ranlib
checking command to parse /opt/STM/STLinux-2.2/devkit/sh4/bin/sh4-linux-nm -B output from sh4-linux-gcc object... ok
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if sh4-linux-gcc supports -fno-rtti -fno-exceptions... no
checking for sh4-linux-gcc option to produce PIC... -fPIC -DPIC
checking if sh4-linux-gcc PIC flag -fPIC -DPIC works... yes
checking if sh4-linux-gcc static flag -static works... yes
checking if sh4-linux-gcc supports -c -o file.o... yes
checking if sh4-linux-gcc supports -c -o file.o... (cached) yes
checking whether the sh4-linux-gcc linker (/opt/STM/STLinux-2.2/devkit/sh4/sh4-linux/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for ANSI C header files... (cached) yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for working strtod... no
checking for pow... no
checking for pow in -lm... yes
checking for memset... yes
checking for pow... (cached) no
checking for pow in -lm... (cached) yes
checking for zlibVersion in -lz... yes
checking if assembler code in pnggccrd.c can be compiled without PNG_NO_MMX_CODE... yes
checking if libraries can be versioned... yes
checking for symbol prefix...
configure: pkgconfig directory is ${libdir}/pkgconfig
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libpng.pc
config.status: creating libpng-config
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands

물론 크로스 컴파일이므로
make check는 "cannot execute binary file" 메시지를 출력하면서 중단된다.
Posted by 구차니
sed '/s/replace old/replace new/'
스트림이니까, 파이프로 연결해도 당연히(?!) 된다.

[링크 : http://www.grymoire.com/Unix/Sed.html]
Posted by 구차니
awk의 가장 유용한 사용방법은
awk '{print $1}' 가 아닐까 생각이 된다.
일단 1번부터 시작하여 n 번째의 문자열을 출력해주며
문자열은 공백으로 구분한다.

예를 들어
/proc/cmdline의 경우
$ cat /proc/cmdline
ro root=/dev/VolGroup00/LogVol00 rhgb quiet

인데 awk를 사용할 경우
$ cat /proc/cmdline | awk '{print $1}'
ro
$ cat /proc/cmdline | awk '{print $2}'
root=/dev/VolGroup00/LogVol00
$ cat /proc/cmdline | awk '{print $3}'
rhgb
$ cat /proc/cmdline | awk '{print $4}'
quiet
$ cat /proc/cmdline | awk '{print $5}'

이런식으로 구분을 하여 옵션별로 떼어낼 수 있다.


$ cat /proc/cmdline | awk '{print NF}'
4
NF는 내부 변수로 컬럼의 갯수를 알려준다.


[링크 : http://www.grymoire.com/Unix/]
Posted by 구차니
프로그램 사용/busybox2009. 7. 30. 17:24

#!/bin/sh

/bin/run-parts --arg=$1 /etc/udhcpc.d

[링크 : http://www.doit.org/udhcpc/udhcpc.script]

#!/bin/sh
# /etc/init.d/udhcpc: start or stop udhcpc client

set -e

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/sbin/udhcpc

test -x $DAEMON || exit 0

case "$1" in
  start)
    echo -n "Starting DHCP client: udhcpc"
    start-stop-daemon --start --quiet --exec $DAEMON \
      -- --script=/etc/udhcpc.script || echo -n " already running"
    echo "."
  ;;

  restart)
    /etc/init.d/udhcpc stop
    /etc/init.d/udhcpc start
  ;;

  reload)
  ;;

  force-reload)
  ;;

  stop)
    echo -n "Stopping DHCP client: udhcpc"
    start-stop-daemon --stop --quiet --exec $DAEMON || echo -n " not running"
    echo "."
  ;;

  renew)
    start-stop-daemon --signal USR1 --stop --quiet --exec $DAEMON || echo -n " not running"
  ;;

  release)
    start-stop-daemon --signal USR2 --stop --quiet --exec $DAEMON || echo -n " not running"
  ;;

  *)
    echo "Usage: /etc/init.d/udhcpc {start|stop|restart|reload|force-reload}"
    exit 1
    ;;
esac

exit 0

[링크 : http://www.doit.org/udhcpc/udhcpc]

[링크 : http://www.doit.org/udhcpc/]
Posted by 구차니
프로그램 사용/busybox2009. 7. 30. 13:16
menu 'Build Options'

config CONFIG_STATIC
    bool "Build BusyBox as a static binary (no shared libs)"
    default n
    help
      If you want to build a static BusyBox binary, which does not
      use or require any shared libraries, then enable this option.
      This can cause BusyBox to be considerably larger, so you should
      leave this option false unless you have a good reason (i.e.
      your target platform does not support shared libraries, or
      you are building an initrd which doesn't need anything but
      BusyBox, etc).

      Most people will leave this set to 'N'.

[링크 : http://stablebox.googlecode.com/svn/trunk/Config.in]

비지박스를 컴파일 하면, 용량이 생각보다 크다.
이 경우에는 위의 옵션을 꺼주면 컴팩트해진다.

1.10.4 기준으로 1.6M에서 600K 정도로 용량이 줄어드는데,
확신할 수는 없지만, 이 옵션을 사용했기 때문에 DNS resolv를 하지 못하는 것 같다.
busybox에서 ping이나 telnet 이 resolv 실패가 뜨면

libresolv.so
libdns.so

를 복사 해주면 되는데, 이 옵션의 영향이 아닐까 생각이된다.
Posted by 구차니
프로그램 사용/busybox2009. 7. 29. 15:13
$ ls /bin/udhcpc*
lrwxrwxrwx 1 root     root 7 Jul 29 14:49 udhcpc -> busybox
lrwxrwxrwx 1 root     root 7 Jul 29 14:49 udhcpd -> busybox

요즘 busybox는 udhcp 라는 dhcp 서버/클라이언트가 내장되어있다.
물론 기본값으로 busybox에 포함되긴 하지만, 확인 후 사용해야 한다.

아무튼, 옵션은 설정되어 있었음에도 불구하고
심볼릭 링크와, 스크립트가 생성되어 있지 않았다.


/sbin/udhcpc - udhcp Client
/sbin/udhcpd - udhcp Daemon
/usr/share/udhcpc/default.script - 기본 dhcp 스크립트




Posted by 구차니
sftp는 ssh를 이용한 ftp이다.
별다르게 설정하지 않았다면, 기본값으로 ssh를 통해 sftp로 전송이 가능하다.

SYNOPSIS
     sftp [-1Cv] [-B buffer_size] [-b batchfile] [-F ssh_config]
          [-o ssh_option] [-P sftp_server_path] [-R num_requests] [-S program]
          [-s subsystem | sftp_server] host
     sftp [[user@]host[:file [file]]]
     sftp [[user@]host[:dir[/]]]
     sftp -b batchfile [user@]host

사용방법은 위와 같은데 간단하게 예를 들자면,

# sftp root@192.168.10.10:/home.tar home.tar
Connecting to 192.168.10.10...
root@192.168.10.10's password:
Fetching /home.tar to home.tar
/home.tar                                       8% 1811MB   6.3MB/s   49:58 ETA

처럼 사용하면 된다. 머랄까.. 저 형식은 cvs나 svn 포맷같기도 하고..
Posted by 구차니
프로그램 사용/busybox2009. 7. 23. 14:45
busy 박스의 문제라기 보다는 라이브러리의 문제인 듯 하다.

ld-linux.so.2
libc.so.6
libdl.so.2
libnss_dns.so.2
libnss_files.so.2
libpthread.so.0
libresolv.so.2

이번 경우에는 libresolv.so 가 없어서 dns resolv가 되지 않았었다.

[링크 : http://kelp.or.kr/korweblog/stories.php?story=05/04/03/4168817]
Posted by 구차니