联系我们 - 广告服务 - 联系电话:
您的当前位置: > 关注 > > 正文

每日观察!cmake-3.19.6-Linux自解压程序 简单的自解压程序

来源:CSDN 时间:2023-01-06 08:19:06


(资料图片)

Linux 自解压程序 简单的自解压程序 生成可执行程序 执行自解压程序 脚本 autopack_run.sh 简单的自解压程序 参考cmake-3.19.6-Linux-x86_64 写了一个自解压的可执行程序

生成可执行程序

cat ./autopack_run.sh test.tar.gz > test_auto_run.sh

执行自解压程序 方法1: sh 直接执行

ssh test_auto_run.sh

方法2:增加可执行权限

chmod +x test_auto_run.sh./test_auto_run.sh

脚本 autopack_run.sh

#!/bin/shMY_APPNAME="autopack_run"MY_VERSION="1.0.0"MY_COPYRIGHT="Copyright (c) Allen"UNPACK_SUBDIR="DATA_DIR"TAR_GZ_START_LINE=$(awk "/^__STARTS_TAR_GZ_FILE_HERE__/ {print NR + 1; exit 0; }" "$0")#interactive=TRUEinteractive=FALSE# Display usageautopack_runusage(){  cat < /dev/null 2> /dev/null; then    autopack_runusage  fi    if echo $a | grep "^--version" > /dev/null 2> /dev/null; then    autopack_runversion    exit 2  fi  if echo $a | grep "^--include-subdir" > /dev/null 2> /dev/null; then    autopack_runinclude_subdir=TRUE  fi  if echo $a | grep "^--exclude-subdir" > /dev/null 2> /dev/null; then    autopack_runinclude_subdir=FALSE  fidoneif [ "x${autopack_runinclude_subdir}x" != "xx" ]then  interactive=FALSEfiautopack_runversionecho "This is a self-extracting archive."toplevel="`pwd`"if [ "x${autopack_runprefix_dir}x" != "xx" ]then  toplevel="${autopack_runprefix_dir}"fiecho "The archive will be extracted to: ${toplevel}"if [ "x${interactive}x" = "xTRUEx" ]then  echo ""  echo "If you want to stop extracting, please press ."  if [ "x${autopack_runinclude_subdir}x" = "xx" ]  then    echo "Do you want to include the subdirectory ${UNPACK_SUBDIR}?"    echo "Saying yes will install in: \"${toplevel}/${UNPACK_SUBDIR}\" "        echo "Saying no  will install in: \"${toplevel}\" [Yn]: "    read line leftover    autopack_runinclude_subdir=TRUE    case ${line} in      n* | N*)        autopack_runinclude_subdir=FALSE    esac  fifi  if [ "x${autopack_runinclude_subdir}x" = "xTRUEx" ]then  toplevel="${toplevel}/${UNPACK_SUBDIR}"  mkdir -p "${toplevel}"fiechoecho "Using target directory: ${toplevel}"echo "Extracting, please wait..."echo ""# so at first try to tail some file to see if tail fails if used with "-n"# if so, don"t use "-n"use_new_tail_syntax="-n"tail $use_new_tail_syntax +1 "$0" > /dev/null 2> /dev/null || use_new_tail_syntax=""extractor="tar xvzf -"tail $use_new_tail_syntax +${TAR_GZ_START_LINE} "$0" | (cd "${toplevel}" && ${extractor}) || autopack_runecho_exit "Problem unpacking the ${UNPACK_SUBDIR}"echo "Unpacking finished successfully. File List:"ls -l ${UNPACK_SUBDIR}exit 0#-----------------------------------------------------------#      Start of TAR.GZ file#-----------------------------------------------------------;__STARTS_TAR_GZ_FILE_HERE__
责任编辑:

标签:

相关推荐:

精彩放送:

新闻聚焦
Top