Fernando, compila o Shell com o gccÂ
Enviado do Yahoo Mail no Android
Em ter, 26 26e set 26e 2017 à s 17:12, Fernando Mercês ***@gmail.com [shell-script]&It;shell-***@yahoogrupos.com.br> escreveu: Â
O shc é o cara pra isso, mas tem pelo menos duas abordagens aÃ:
1. Escrever um parser que vai gerar código de uma linguagem compilada (C por exemplo) a partir de shell. Isso seria o terror. rs2. Passar o conteúdo de um script para o interpretador do shell, a partir de um compilado.
Na abordagem 2, um código embrionário seria:
#include <stdio.h>#include <stdlib.h>
int main(int argc, char *argv[]) {
char buff[] = "echo 3+3|bc\n" \Â Â Â Â Â Â Â Â Â "for i in {1..5}; do" \Â Â Â Â Â Â Â Â Â " Â echo $i\n" \Â Â Â Â Â Â Â Â Â "done\n" \Â Â Â Â Â Â Â Â Â "pwd\n";
system(buff);
return 0;}
Ao compilar e executar, você tem a seguinte saÃda:
$ gcc -o a a.c$ ./a612345/tmp
Funciona, mas tem maneiras melhores. Ao invés de usar um buffer de char, poderia ler de um arquivo (o script), ao invés de usar a system(), criar um pipe para o binário do bash com o a popen [1], etc. Ou simplesmente usar o shc. O.o
A necessidade é esconder o código do script? Ter mais performance? Qual a treta? rs
Abraço.
[1]Â http://man7.org/linux/man-pages/man3/popen.3.html
Att,
@MercesFernando
mentebinaria.com.br
---------------------------
2017-09-26 11:46 GMT-03:00 Gilberto Nunes ***@gmail.com [shell-script] <shell-***@yahoogrupos.com.br>:
Â
Bom dia amigos
Eu ia perguntar aqui na lista como criar um executável binário, a partir de um shell...Mas antes fiz uma pesquisa no google e achei isso:
https://tecadmin.net/create- binary-file-from-shell-script/
Pode ajudar mais alguém... A propósito se alguém souber método diferente, compartilha aÃ
Abraço
---Gilberto Ferreira
Consultor TI Linux | IaaS Proxmox, CloudStack, KVM | Zentyal Server | Zimbra Mail Server
(47) 3025-5907(47) 99676-7530
Skype: gilberto.nunes36
konnectati.com.br
https://www.youtube.com/watch? v=2rkgOxuyuu8
#yiv3752784115 #yiv3752784115 -- #yiv3752784115ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv3752784115 #yiv3752784115ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv3752784115 #yiv3752784115ygrp-mkp #yiv3752784115hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv3752784115 #yiv3752784115ygrp-mkp #yiv3752784115ads {margin-bottom:10px;}#yiv3752784115 #yiv3752784115ygrp-mkp .yiv3752784115ad {padding:0 0;}#yiv3752784115 #yiv3752784115ygrp-mkp .yiv3752784115ad p {margin:0;}#yiv3752784115 #yiv3752784115ygrp-mkp .yiv3752784115ad a {color:#0000ff;text-decoration:none;}#yiv3752784115 #yiv3752784115ygrp-sponsor #yiv3752784115ygrp-lc {font-family:Arial;}#yiv3752784115 #yiv3752784115ygrp-sponsor #yiv3752784115ygrp-lc #yiv3752784115hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv3752784115 #yiv3752784115ygrp-sponsor #yiv3752784115ygrp-lc .yiv3752784115ad {margin-bottom:10px;padding:0 0;}#yiv3752784115 #yiv3752784115actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv3752784115 #yiv3752784115activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv3752784115 #yiv3752784115activity span {font-weight:700;}#yiv3752784115 #yiv3752784115activity span:first-child {text-transform:uppercase;}#yiv3752784115 #yiv3752784115activity span a {color:#5085b6;text-decoration:none;}#yiv3752784115 #yiv3752784115activity span span {color:#ff7900;}#yiv3752784115 #yiv3752784115activity span .yiv3752784115underline {text-decoration:underline;}#yiv3752784115 .yiv3752784115attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv3752784115 .yiv3752784115attach div a {text-decoration:none;}#yiv3752784115 .yiv3752784115attach img {border:none;padding-right:5px;}#yiv3752784115 .yiv3752784115attach label {display:block;margin-bottom:5px;}#yiv3752784115 .yiv3752784115attach label a {text-decoration:none;}#yiv3752784115 blockquote {margin:0 0 0 4px;}#yiv3752784115 .yiv3752784115bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv3752784115 .yiv3752784115bold a {text-decoration:none;}#yiv3752784115 dd.yiv3752784115last p a {font-family:Verdana;font-weight:700;}#yiv3752784115 dd.yiv3752784115last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv3752784115 dd.yiv3752784115last p span.yiv3752784115yshortcuts {margin-right:0;}#yiv3752784115 div.yiv3752784115attach-table div div a {text-decoration:none;}#yiv3752784115 div.yiv3752784115attach-table {width:400px;}#yiv3752784115 div.yiv3752784115file-title a, #yiv3752784115 div.yiv3752784115file-title a:active, #yiv3752784115 div.yiv3752784115file-title a:hover, #yiv3752784115 div.yiv3752784115file-title a:visited {text-decoration:none;}#yiv3752784115 div.yiv3752784115photo-title a, #yiv3752784115 div.yiv3752784115photo-title a:active, #yiv3752784115 div.yiv3752784115photo-title a:hover, #yiv3752784115 div.yiv3752784115photo-title a:visited {text-decoration:none;}#yiv3752784115 div#yiv3752784115ygrp-mlmsg #yiv3752784115ygrp-msg p a span.yiv3752784115yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv3752784115 .yiv3752784115green {color:#628c2a;}#yiv3752784115 .yiv3752784115MsoNormal {margin:0 0 0 0;}#yiv3752784115 o {font-size:0;}#yiv3752784115 #yiv3752784115photos div {float:left;width:72px;}#yiv3752784115 #yiv3752784115photos div div {border:1px solid #666666;min-height:62px;overflow:hidden;width:62px;}#yiv3752784115 #yiv3752784115photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv3752784115 #yiv3752784115reco-category {font-size:77%;}#yiv3752784115 #yiv3752784115reco-desc {font-size:77%;}#yiv3752784115 .yiv3752784115replbq {margin:4px;}#yiv3752784115 #yiv3752784115ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv3752784115 #yiv3752784115ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv3752784115 #yiv3752784115ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv3752784115 #yiv3752784115ygrp-mlmsg select, #yiv3752784115 input, #yiv3752784115 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv3752784115 #yiv3752784115ygrp-mlmsg pre, #yiv3752784115 code {font:115% monospace;}#yiv3752784115 #yiv3752784115ygrp-mlmsg * {line-height:1.22em;}#yiv3752784115 #yiv3752784115ygrp-mlmsg #yiv3752784115logo {padding-bottom:10px;}#yiv3752784115 #yiv3752784115ygrp-msg p a {font-family:Verdana;}#yiv3752784115 #yiv3752784115ygrp-msg p#yiv3752784115attach-count span {color:#1E66AE;font-weight:700;}#yiv3752784115 #yiv3752784115ygrp-reco #yiv3752784115reco-head {color:#ff7900;font-weight:700;}#yiv3752784115 #yiv3752784115ygrp-reco {margin-bottom:20px;padding:0px;}#yiv3752784115 #yiv3752784115ygrp-sponsor #yiv3752784115ov li a {font-size:130%;text-decoration:none;}#yiv3752784115 #yiv3752784115ygrp-sponsor #yiv3752784115ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv3752784115 #yiv3752784115ygrp-sponsor #yiv3752784115ov ul {margin:0;padding:0 0 0 8px;}#yiv3752784115 #yiv3752784115ygrp-text {font-family:Georgia;}#yiv3752784115 #yiv3752784115ygrp-text p {margin:0 0 1em 0;}#yiv3752784115 #yiv3752784115ygrp-text tt {font-size:120%;}#yiv3752784115 #yiv3752784115ygrp-vital ul li:last-child {border-right:none !important;}#yiv3752784115