Rocky Linux에서 shc
(Shell Script Compiler)를 설치하는 방법을 정리한다. shc
는 쉘 스크립트를 컴파일하여 바이너리 실행파일로 변환하는 도구로 사용된다.
참고 사이트
- https://linux.die.net/man/1/shc
- https://github.com/neurobin/shc
- https://rhel.pkgs.org/8/epel-x86_64/shc-4.0.3-1.el8.x86_64.rpm.html
- https://neurobin.org/projects/softwares/unix/shc/
1. 필수 패키지 설치
먼저, shc
를 빌드하기 위해 필요한 패키지를 설치한다.
sudo dnf install -y gcc make
2. shc
다운로드 및 빌드
shc
소스 코드 다운로드
cd /tmp
wget https://github.com/neurobin/shc/archive/refs/tags/4.0.3.tar.gz
tar xzf 4.0.3.tar.gz
cd shc-4.0.3
shc
빌드 및 설치
./configure
make
sudo make install
3. shc
사용 예제
쉘 스크립트를 바이너리로 변환하는 예제
- 샘플 쉘 스크립트 작성
echo -e '#!/bin/bash\necho "Hello, World!"' > hello.sh
chmod +x hello.sh
shc
를 사용하여 쉘 스크립트를 바이너리로 변환
shc -f hello.sh
hello.sh.x
라는 실행 파일을 생성한다.
- 생성된 바이너리 실행
./hello.sh.x
요약
- 필수 패키지(
gcc
,make
) 설치 shc
소스 코드 다운로드 및 빌드shc
를 사용하여 쉘 스크립트를 바이너리로 변환
이 과정을 통해 Rocky Linux에 shc
를 설치하고 사용할 수 있으며, 추가적인 설정이나 필요에 따라 스크립트를 수정하여 사용할 수 있다.
'IT > 리눅스' 카테고리의 다른 글
리눅스 명령어 man 검색 시 나타나는 괄호의 숫자 의미 (0) | 2024.08.13 |
---|---|
yum groupinstall (dnf group install) 이란? (0) | 2024.08.08 |
Java 여러 버전 설치, 관리하기 (update-alternatives) (0) | 2024.08.04 |
마리아디비(MariaDB) 덤프 생성하기 (0) | 2024.07.29 |
마리아디비(MariaDB) 백업 설정 (0) | 2024.07.26 |