1、安装编译软件,编译后生成shc
文件就是命令程序
yum install glibc-devel gcc c++ -y
cd /usr/src
wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.9.tgz
tar xzf shc-3.8.9.tgz
cd shc-3.8.9/
make
查看帮助手册
[root@localhost shc-3.8.9]# ./shc -help
shc Version 3.8.9, Generic Script Compiler
shc Copyright (c) 1994-2012 Francisco Rosales <frosal@fi.upm.es>
shc Usage: shc [-e date] [-m addr] [-i iopt] [-x cmnd] [-l lopt] [-rvDTCAh] -f script
-e %s Expiration date in dd/mm/yyyy format [none]
-m %s Message to display upon expiration ["Please contact your provider"]
-f %s File name of the script to compile
-i %s Inline option for the shell interpreter i.e: -e
-x %s eXec command, as a printf format i.e: exec('%s',@ARGV);
-l %s Last shell option i.e: --
-r Relax security. Make a redistributable binary
-v Verbose compilation
-D Switch ON debug exec calls [OFF]
-T Allow binary to be traceable [no]
-C Display license and exit
-A Display abstract and exit
-h Display help and exit
Environment variables used:
Name Default Usage
CC cc C compiler command
CFLAGS <none> C compiler flags
Please consult the shc(1) man page.
2、编写 test.sh 测试脚本
[root@localhost shc-3.8.9]# cat /root/test.sh
#!/bin/bash
echo 'Hello Test!'
3、编译脚本,生成可执行文件
[root@localhost shc-3.8.9]# ./shc -v -r -T -f /root/test.sh
shc shll=bash
shc [-i]=-c
shc [-x]=exec '%s' "$@"
shc [-l]=
shc opts=
shc: cc /root/test.sh.x.c -o /root/test.sh.x
shc: strip /root/test.sh.x
shc: chmod go-r /root/test.sh.x
4、编译后生成的 /root/test.sh.x
文件就是可执行文件
[root@localhost shc-3.8.9]# /root/test.sh.x
Hello Test!
END
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有