如何bash的文件转换为二进制可执行文件 [英] How to convert bash file to a binary executable

查看:213
本文介绍了如何bash的文件转换为二进制可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过SHC创建从bash脚本Linux服务器上的二进制可执行文件。创建二进制工作在Linux机器很好,但通过在Mac上的错误。我怎么能转换我的bash文件,二进制可执行文件,能够到处运行(Ubuntu的,CentOS的,苹果,Cygwin的)?

  SHC -v -r -t -f ir16fetcher.sh
    MV ir16fetcher.sh.x ir16fetcher

我的bash脚本的家当

 #!/斌/庆典

在Linux机器

  ./ir16installer
    用法:ir16fetcher<服务器名/ IP地址> [第n个最新版本 - 可选。默认值1]
    实例:ir16fetcher贾格尔2
    实例:ir16fetcher 167.116.6.155
    要求:请在安装文件夹〜/ IRinstall / ir16和放一定的conf文件; 〜/ IRinstall / irmanager

在我的Mac

  ./ir16installer
    -bash:./ir16installer:不能执行二进制文件


解决方案

您必须对您需要支持的每一个体系结构和操作系统做到这一点。在任何情况下,存在没有真正似乎是使用用于分配该方法的任何好处。它增加了依赖和复杂化交付,我pretty确保任何混淆了特困编译器实现是很容易逆转。

I created a binary executable from bash script on linux server through SHC. The binary created works fine on linux machines, but through mistake on Mac. How could I convert my bash file to binary executable that is able to run everywhere(ubuntu, CentOS, Mac, Cygwin)?

    shc -v -r -T -f ir16fetcher.sh
    mv ir16fetcher.sh.x ir16fetcher

Shebang of my bash script

    #!/bin/bash

On Linux machines

    ./ir16installer 
    USAGE  : ir16fetcher <servername/ip address> [the n th latest build - optional. Default 1]
    EXAMPLE: ir16fetcher jagger 2
    EXAMPLE: ir16fetcher 167.116.6.155
    REQUIRE: Please make sure conf file in installation folder ~/IRinstall/ir16 & ~/IRinstall/irmanager

On my Mac

    ./ir16installer 
    -bash: ./ir16installer: cannot execute binary file

解决方案

You will have to do this for every architecture and operating system you need to support. In any case, there doesn't really seem to be any benefits of using this method for distribution. It adds dependencies and complicates delivery, and I'm pretty sure whatever obfuscation the "shc" compiler implements is easily reversed.

这篇关于如何bash的文件转换为二进制可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆