Dúvida sobre Shell Script

1. Dúvida sobre Shell Script

Perfil removido
removido

(usa Nenhuma)

Enviado em 10/10/2018 - 21:01h

Olá, queria saber se este fórum serve apenas para problemas relacionados ao Linux ou eu poderia pedir a ajuda de vcs com algo que me surgiu ultimamente. Vcs me ajudariam a criar um shell script pra rodar no terminal do linux e se possível no power shell do windows também? Como eu atualmente não tenho os conhecimentos necessários para prosseguir sozinho queria pedir (implorar!) por sua atenção. Eu tenho a ideia completa só preciso de assessoramento. Será um desafio que lhes dará mais conhecimento, eu espero. Posso deixar meu whats ou email aqui?




  


2. Re: Dúvida sobre Shell Script

Marcelo Oliver
msoliver

(usa Debian)

Enviado em 10/10/2018 - 23:59h

b3f7 escreveu:

Olá, queria saber se este fórum serve apenas para problemas relacionados ao Linux ou eu poderia pedir a ajuda de vcs com algo que me surgiu ultimamente. Vcs me ajudariam a criar um shell script pra rodar no terminal do linux e se possível no power shell do windows também? Como eu atualmente não tenho os conhecimentos necessários para prosseguir sozinho queria pedir (implorar!) por sua atenção. Eu tenho a ideia completa só preciso de assessoramento. Será um desafio que lhes dará mais conhecimento, eu espero. Posso deixar meu whats ou email aqui?



Boa noite.
Poste o que precisa para que possamos te ajudar...

Att.:
Marcelo Oliver


3. Re: Dúvida sobre Shell Script

Paulo
paulo1205

(usa Ubuntu)

Enviado em 11/10/2018 - 08:30h

Acho que perguntar não ofende.

Considere, porém, que o Power Shell, conquanto seja uma ferramenta muito interessante e, de certa forma, até esteja disponível também no mundo Linux (PowerShell Core, da própria Microsoft), é bem diferente do que se entende tradicionalmente por shell script fora do mundo Microsoft.


4. Re: Dúvida sobre Shell Script

Daniel Lara Souza
danniel-lara

(usa Fedora)

Enviado em 11/10/2018 - 14:25h

tu podes pesquisar pela ferramenta ansible
pois pode de ajudar com ambiente windows e linux para automatizar algumas tarefas
http://ansible-br.org/




5. Re: Dúvida sobre Shell Script

Perfil removido
removido

(usa Nenhuma)

Enviado em 11/10/2018 - 14:48h

paulo1205 escreveu:

Acho que perguntar não ofende.

Considere, porém, que o Power Shell, conquanto seja uma ferramenta muito interessante e, de certa forma, até esteja disponível também no mundo Linux (PowerShell Core, da própria Microsoft), é bem diferente do que se entende tradicionalmente por shell script fora do mundo Microsoft.


Interessante, sabe me dizer qual desses dois tem maior capacidade e facilidade pra gerar aleatoriedade em operações simples de aritmética?



6. Re: Dúvida sobre Shell Script

Perfil removido
removido

(usa Nenhuma)

Enviado em 11/10/2018 - 14:50h

danniel-lara escreveu:

tu podes pesquisar pela ferramenta ansible
pois pode de ajudar com ambiente windows e linux para automatizar algumas tarefas
http://ansible-br.org/



Muito complexo! Preciso de um código que com uma pergunta matemática simples gere gere a resposta e alternativas.


7. Re: Dúvida sobre Shell Script

Perfil removido
removido

(usa Nenhuma)

Enviado em 11/10/2018 - 15:03h

msoliver escreveu:

b3f7 escreveu:

Olá, queria saber se este fórum serve apenas para problemas relacionados ao Linux ou eu poderia pedir a ajuda de vcs com algo que me surgiu ultimamente. Vcs me ajudariam a criar um shell script pra rodar no terminal do linux e se possível no power shell do windows também? Como eu atualmente não tenho os conhecimentos necessários para prosseguir sozinho queria pedir (implorar!) por sua atenção. Eu tenho a ideia completa só preciso de assessoramento. Será um desafio que lhes dará mais conhecimento, eu espero. Posso deixar meu whats ou email aqui?



Boa noite.
Poste o que precisa para que possamos te ajudar...

Att.:
Marcelo Oliver


Marcelo, obrigado pela atenção. Eu uma vez tava editando um código .bat do Windows e achei muito legal mas percebi que era limitado. No Linux eu percebi que os scripts terminados em .sh eram, aparentemente, mais complexos e por isso eu quero ver se consigo criar um "produto" que é o meu objetivo final. Preciso saber se é possível usar algum código que gere aleatoriedade em perguntas bem básicas de aritmética, assim eu poderei, a partir de um código original, copiá-lo e modificá-lo para se passar por um programa para "ajudar crianças a se interessarem pela matemática através de um terminal". Acho que outras linguagens de programação seriam mais complexas e aprofundadas. Preciso de algo simples, nem de interface gráfica eu preciso. Minha ideia é a seguinte: Eu crio o corpo genérico de uma pergunta e o código gera aleatoriamente o cálculo, a resposta, as alternativas e uma saída para caso a entrada seja correta ou errada. Vou detalhar: digamos que o corpo genérico da pergunta seja "Agora vamos brincar de acertar a multiplicação (aqui eu posso mudar e colocar adição, subtração, divisão) no menor tempo que você conseguir!", nessa parte o código faz multiplicação e todos os detalhes que eu já passei. Viram que agora tem temporizador?! Dá pra fazer isso em script?



8. Re: Dúvida sobre Shell Script

Marcelo Oliver
msoliver

(usa Debian)

Enviado em 11/10/2018 - 19:53h

b3f7 escreveu:

msoliver escreveu:

b3f7 escreveu:

Olá, queria saber se este fórum serve apenas para problemas relacionados ao Linux ou eu poderia pedir a ajuda de vcs com algo que me surgiu ultimamente. Vcs me ajudariam a criar um shell script pra rodar no terminal do linux e se possível no power shell do windows também? Como eu atualmente não tenho os conhecimentos necessários para prosseguir sozinho queria pedir (implorar!) por sua atenção. Eu tenho a ideia completa só preciso de assessoramento. Será um desafio que lhes dará mais conhecimento, eu espero. Posso deixar meu whats ou email aqui?



Boa noite.
Poste o que precisa para que possamos te ajudar...

Att.:
Marcelo Oliver


Marcelo, obrigado pela atenção.
Eu uma vez tava editando um código .bat do Windows e achei muito legal mas percebi que era limitado.
No Linux eu percebi que os scripts terminados em .sh eram, aparentemente, mais complexos e por isso eu quero ver se consigo criar um "produto" que é o meu objetivo final. Preciso saber se é possível usar algum código que gere aleatoriedade em perguntas bem básicas de aritmética, assim eu poderei, a partir de um código original, copiá-lo e modificá-lo para se passar por um programa para "ajudar crianças a se interessarem pela matemática através de um terminal". Acho que outras linguagens de programação seriam mais complexas e aprofundadas. Preciso de algo simples, nem de interface gráfica eu preciso. Minha ideia é a seguinte: Eu crio o corpo genérico de uma pergunta e o código gera aleatoriamente o cálculo, a resposta, as alternativas e uma saída para caso a entrada seja correta ou errada. Vou detalhar: digamos que o corpo genérico da pergunta seja "Agora vamos brincar de acertar a multiplicação (aqui eu posso mudar e colocar adição, subtração, divisão) no menor tempo que você conseguir!", nessa parte o código faz multiplicação e todos os detalhes que eu já passei. Viram que agora tem temporizador?! Dá pra fazer isso em script?


Boa noite b3f7.
Tenho algo parecido em JavaScript...
No MENU, escolha o tipo de operação.... e o tempo de duração... ai é só brincar....
Fiz já tem um tempo.... para a criançada da família....
Interessa??
Segue o código....
Salve como html.
<!DOCTYPE html>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<!-- Marcelo Oliver | ABRIL/2017-->
<html>
<head>
<title> -- MATEMáTICA V.10 -- </title>
<style>

#CONFIG {
display: block;
margin: auto;
width: 180px;
left:1%;
border: 1px solid #FF0;
padding: 2.5px;
border-radius: 6px;
}

#DIVPT {
display: none;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
left:1%;
right: 1%;
top: 10%;
padding: 2.5px;
border: 3px ridge #FF0;
border-radius: 8px;
}

#DIVTM {
display: none;
position: fixed;
margin: auto;
width: 7.5%;
max-height: 520px;
right: 0.5%;
top: 5%;
padding: 2.5px;
border: 3px ridge #000;
border-radius: 8px;
}

#DIVSW {
display: none;
position: fixed;
margin: auto;
width: 7.5%;
max-height: 520px;
right: 0.5%;
top: 15%;
padding: 2.5px;
border: 3px ridge #000;
border-radius: 8px;
}

#DIV00 {
display: none;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
right: 1%;
left:1%;
top: 25%;
padding-top: 2.5px;
padding-right: 2.5px;
padding-bottom: 2.5px;
padding-left: 2.5px;
border: 2.5px ridge black;
border-radius: 8px;
}

#DIV01 {
display: none;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
right: 1%;
left:1%;
bottom: 20%;
padding: 2.5px;
border: 2.5px ridge black;
border-radius: 8px;
}

#DIV02 {
display: none;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
right: 1%;
left:1%;
top: 24%;
padding: 2.5px;
border: 2.5px ridge black;
border-radius: 8px;
}

#DIV03 {
display: block;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
right: 1%;
left:1%;
top: 15%;
padding: 25px;
border: 2.5px ridge black;
border-radius: 8px;
}

#DIVALERTA {
display: none;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
right: 1%;
left:1%;
top: 30%;
padding: 2.5px;
border: 2.5px ridge black;
border-radius: 8px;
}

div.top {
margin: auto;
top: 1.5%;
width: 50%;
right: 25%;
background-color: #FFF;
border: 2.5px ridge black;
padding: 2px;
border-radius: 8px;
}

input[type=number]{
font-size:1.8em;
width:4.5em;
padding-top: 2.5px;
padding-right: 2.5px;
padding-bottom: 2.5px;
padding-left: 2.5px;
margin:1;
border:1px solid #ddd;
border-radius:5px;
text-align:center;
}

input[type=text]{
font-size:1.8em;
width:4.5em;
padding-top: 2.5px;
padding-right: 2.5px;
padding-bottom: 2.5px;
padding-left: 2.5px;
margin:1;
border:1px solid #ddd;
border-radius:5px;
text-align:center;
}

input[type=color]{
font-size:1.4em;
width:4em;
padding-top: 2px;
padding-right: 2px;
padding-bottom: 2px;
padding-left: 2px;
border:5px solid #000;
border-radius:5px;
}

form.style1 fieldset {
align: center;
margin: auto;
border:1px solid black;
border-radius: 5px;
padding-top: 7.5px;
padding-right: 2.5px;
padding-bottom: 7.5px;
padding-left: 2.5px;
width: 80%;
}

form.style1 legend {
align: center;
padding: 0.2em 0.5em;
border:1px solid black;
border-radius: 5px;
color:black;
font-size:0%;
text-align:right;
}

form.style1 input {
border:0.5px ridge #000;
border-radius: 8px;
}

form.style2 fieldset {
align: center;
margin: auto;
border:1px solid #FF0;
border-radius: 5px;
padding-top: 7.5px;
padding-right: 2.5px;
padding-bottom: 7.5px;
padding-left: 2.5px;
width: 90%;
}

div.fixedB {
position: fixed;
margin: auto;
text-align: center;
bottom: 0%;
width: 50%;
right: 25%;
background-color: #FFF;
border: 1px solid #000;
padding: 0.5px;
border-radius: 6px;
}

div.fixedT {
background-color: #FFF;
margin: auto;
position: fixed;
width: 18%;
text-align: center;
top: 0.25%;
right: 41%;
border: 0px ridge #000;
padding: 0px;
border-radius: 8px;

}

#w00 {
line-height: 0.125;
color: white;
text-shadow: 2px 2px 4px #000;
text-align: center;
}

#w01 {
line-height: 0.125;
color: #FF0;
text-shadow: 2px 2px 4px #000;
text-align: center;
}

#w02 {
line-height: 0.125;
color: #00F;
text-shadow: 2px 2px 4px #000;
text-align: center;
}

#p00 {
line-height: 0.6125;
letter-spacing: 0.25px;
font-size: 3.6em;
text-shadow: 2px 2px 4px #000;
}

#p01 {
line-height: 0.8;
letter-spacing: 0.25px;
font-size: 28px;
text-shadow: 2px 2px 4px #00F;
}

#p03 {
text-align: center;
line-height: 0;
letter-spacing: 0.25px;
}

#h1000 {
line-height: 0.125;
color: white;
text-shadow: 1px 2px 4px #000;
text-align: center;
}

#h1001 {
line-height: 0.125;
color: yellow;
text-shadow: 1px 2px 4px #000;
text-align: center;
}

#h1002 {
line-height: 0.125;
color: blue;
text-shadow: 1px 2px 4px #000;
text-align: center;
}

#h1003 {
line-height: 1.25;
color: #00F;
text-shadow: 2px 2px 6px #00F;
}

.button00 {
background-color: #FF0;
border: 1.25px solid #000;
border-radius: 4px;
color: #000;
padding: 2.5px 5px;
text-align: center;
font-size: 14px;
cursor: pointer;
}

.button {
background-color: #FF0;
border: 1.25px solid #000;
border-radius: 6px;
color: #000;
padding: 2.5px 5px;
text-align: center;
text-decoration: none;
outline: none;
display: inline-block;
font-size: 18px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.5s;
cursor: pointer;
box-shadow: 0 0px #FFF;
}

.button:hover {
background-color: #6666FF;
}

.button:active {
background-color: #555555;
box-shadow: 0 5px #666;
transform: translateY(5px);0.1
}

hr {
border-style: inset;
border-width: 2px;
color:yellow;
width: 90%;
}

div.fixedTL {
position: fixed;
margin: auto;
text-align: left;
top: 2%;
width: 8%;
left: 0.5%;
height: 25px;
}

div.fixedTR {
position: fixed;
margin: auto;
text-align: right;
top: 2%;
width: 12%;
right: 0.5%;
height: 25px;
}

.sidenav {
width: 0%;
position: fixed;
z-index: 1;
top: 2%;
left: 0.5%;
color: #818181;
background-color: #000;
overflow-x: hidden;
transition: 0.25s;
}

.sidenav a {
padding: 2px 2px 2px 16px;
text-decoration: none;
font-size: 12px;
color: #818181;
display: block;
transition: 0.3s
}

.sidenav a:hover, .offcanvas a:focus{
color: #f1f1f1;
}

.sidenav .closebtn {
position: absolute;
top: 0;
right: 2.5px;
font-size: 14px;
margin-left: 0px;
}

@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}

</style>
</head>

<script>
/*DEFINE VARS*/
var myVar, TEMPODUR=0, QTSIG=0;
/*DEFINE VARS [NNSIG=6] */

function INICIAL() {
document.getElementById("mySidenav").style.height = (screen.height - 170)+"px";
document.getElementById('cores').reset();
document.getElementById('sinais').reset();
document.getElementById('tempo').reset();
TEMPODUR = document.getElementById("CDT").innerHTML;
QTSIG = document.getElementById("SIG").innerHTML;
if(TEMPODUR==0 || QTSIG==0){
document.getElementById("h1003").innerHTML = "<hr>MATEMÁTICA PARA CRIANÇAS.<hr>No MENU/Configurações<br>Defina as \"Operações\" e a \"Duração\".<br>CLIQUE [OK] para iniciar<hr>";}
else {document.getElementById("h1003").innerHTML = "<hr>INICIANDO EM 3 SEGUNDOS<hr>";
StartTimer();
document.getElementById('CONFIG').style.display='none';
}
}

function RELOAD() {
window.location.reload(true);
}

function addZero(y,n) {
while (y.toString().length < n) {
y = "0" + y;
}
return y;
}

function ClearForm() {
var LIMPAR = document.getElementById("FieldseTForm0");
while (LIMPAR.hasChildNodes()) {
LIMPAR.removeChild(LIMPAR.lastChild);
}
document.getElementById('DIV00').style.display='block';
document.getElementById('DIV01').style.display='block';
document.getElementById('DIV02').style.display='none';
document.getElementById('form1').reset();
GeraForm()
}

function GeraForm() {
document.getElementById('form1').reset();
//GERA OPERADOR
var n, NN, sgn="", ncp=2, NM=0, TIME=0;
var SIGNAL = ["+", "-", "/", "*", "P", "R" ]; /* X², &#8730;² 8730 221A */
var NNSIG = document.getElementById("SIG").innerHTML;
var N = Math.floor(Math.random() * NNSIG);
sgn = SIGNAL[N];
document.getElementById('sgn').innerHTML = sgn;

//GERA CONTADOR DE FASE/PTOS E ATUALIZA
var CNT = document.getElementById("CNT").innerHTML;
CNT = Number(CNT);
var COUNT = CNT + 1;
document.getElementById("CNT").innerHTML = COUNT;
var COUNT00 = addZero(COUNT, 2);

NM += COUNT+10;
document.getElementById("NMX").innerHTML = NM;

PTS = document.getElementById('PTS').innerHTML;
PTS = Number(PTS);
document.getElementById("h1000").innerHTML = "Fase: "+COUNT00+" # Pontos: " +PTS;

//GERA INPUTS (2 ou 1) resolve o sinal p/ P e R
if(sgn=="R" || sgn=="P"){var ncp = 1;}
for (n=0;n<ncp;n++) {
var x = document.createElement("input");
NN = Math.floor((Math.random() * NM) + 1);
//DEFINE SINAL PARA "P", "R", ETC
if(n>0){document.getElementById("FieldseTForm0").appendChild(document.createTextNode(" "+sgn+" "));}
if(sgn == "R"){SGN = "&#8730;"+NN;}
if(sgn == "P"){SGN = NN+"²";}

x.type = "text";
if(ncp==2){x.value = NN;}
else if(ncp==1){x.value = SGN;}
document.getElementById("C0"+n).innerHTML = NN;
x.readOnly = "readOnly";
x.id = "vl0"+n;
x.step = "0.01";
x.min = "0";
x.size = "6";
document.getElementById("FieldseTForm0").appendChild(x);
}
}

function PEGA_VAR() {
var VL0, VL1, VL2, TTL, sgn, PTS, NP=0, COUNT=0;
COUNT = document.getElementById("CNT").innerHTML;
sgn = document.getElementById('sgn').innerHTML;
if(sgn == "R" || sgn == "P"){VL0 = Number(document.getElementById("C00").innerHTML);}
else{
VL0 = Number(document.getElementById("C00").innerHTML);
VL1 = Number(document.getElementById("C01").innerHTML);
}

VL2 = Number(document.getElementById('vl02').value);
PTS = document.getElementById('PTS').innerHTML;
PTS = Number(PTS);

COUNT = Number(COUNT)
COUNT00 = addZero(COUNT, 2);

if(sgn=="P"){var TTL = Math.pow(VL0, 2);}
else if(sgn=="R"){var TTL = Math.sqrt(VL0);}
else{var TTL = eval(VL0+sgn+VL1);}


var R = /\.[0-9]+/.test(TTL); //VERIFICA SE TEM PONTO NO RESULTADO, SE TIVER, FIXA COM DUAS CASA DECIMAIS E ARREDONDA
if(Number(R) == "1"){TTL = Number(TTL).toFixed(2);}

document.getElementById('DIV00').style.display='none';
document.getElementById('DIV01').style.display='none';
document.getElementById('DIV02').style.display='block';

NP = document.getElementById('NMX').innerHTML;
NP = Number(NP);

if(TTL == VL2){PTS = PTS + NP;
document.getElementById("p00").innerHTML = "<font color=#0F0><b> &#9786; Resposta &#9745;"+"</b>"+"</font>";}

else{PTS = PTS - NP;
document.getElementById("p00").innerHTML = "<font color=#F00><b> &#9785; Resposta &#9746;</b></font><hr><font size=10px> O &#9745; é: "+TTL+"<hr></font>";}

document.getElementById("h1000").innerHTML = "Fase: "+COUNT00+" # Pontos: " + PTS;
document.getElementById('PTS').innerHTML = PTS;
}

function focusFunction() {
document.getElementById("vl02").style.background = "yellow";
}

function StartTimer() {
myVar = setInterval(timer, 1000);
}

function timer() {
t = document.getElementById("TLC").innerHTML;
var t = t - 1;
document.getElementById("TLC").innerHTML = t;
document.getElementById("h1003").innerHTML = "<hr>INICIANDO EM " + t + " SEGUNDO(s).<hr>";
if(t==0){
clearInterval(myVar);
CountDown()
document.getElementById("dtini").innerHTML = new Date().getTime();
document.getElementById('DIVPT').style.display='block';
document.getElementById('DIV00').style.display='block';
document.getElementById('DIV01').style.display='block';
document.getElementById('DIV03').style.display='none';
GeraForm()
}
}

function openNav() {
document.getElementById("mySidenav").style.width = "200px";
}

function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}

function MyColor() {
var COR = document.getElementById("xyz").value;
var TIPO = document.forms[0];
var i, TPCOR;
for (i = 0;i<TIPO.length;i++) {
if (TIPO[i].checked) {TPCOR = TIPO[i].value;}
}
if(TPCOR=="FUNDO") {document.body.style.backgroundColor = COR;}
else if(TPCOR=="FONTE") {document.body.style.color = COR;}
}

function PegaSignal(QTSIG) {
document.getElementById("SIG").innerHTML = QTSIG;
}

function PreCountDown(TEMPODUR) {
document.getElementById("CDT").innerHTML = TEMPODUR;
}

function CountDown() {
TEMPODUR = document.getElementById("CDT").innerHTML;
document.getElementById("dtini").innerHTML = new Date().getTime(); // milisegundos
var DTINI = document.getElementById("dtini").innerHTML;
var datafim = (TEMPODUR * 60 * 1000) + new Date().getTime();
var countDownDate = new Date(datafim).getTime();
var Mdiv = document.getElementById("fixedT");

if(countDownDate > new Date().getTime()) {
Mdiv.style.backgroundColor = "#00FF55";
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
var Min = addZero(Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)), 2);
var Sec = addZero(Math.floor((distance % (1000 * 60)) / 1000), 2);
var Mse = addZero(Math.floor(distance % 1000), 3);

if (distance >= 0) {document.getElementById("p03").innerHTML = Min + ":" + Sec + ":" + Mse;}

else {
var NCor = Math.floor(Math.random() * 139);
var MCor = ["#F0F8FF", "#FAEBD7", "#00FFFF", "#7FFFD4", "#F0FFFF", "#F5F5DC", "#FFE4C4", "#000000", "#FFEBCD", "#0000FF", "#8A2BE2", "#A52A2A", "#DEB887", "#5F9EA0", "#7FFF00", "#D2691E", "#FF7F50", "#6495ED", "#FFF8DC", "#DC143C", "#00008B", "#008B8B", "#B8860B", "#A9A9A9", "#006400", "#BDB76B", "#8B008B", "#556B2F", "#FF8C00", "#9932CC", "#8B0000", "#E9967A", "#8FBC8F", "#483D8B", "#2F4F4F", "#00CED1", "#9400D3", "#FF1493", "#00BFFF", "#696969", "#1E90FF", "#B22222", "#FFFAF0", "#228B22", "#FF00FF", "#DCDCDC", "#F8F8FF", "#FFD700", "#DAA520", "#808080", "#008000", "#ADFF2F", "#F0FFF0", "#FF69B4", "#CD5C5C", "#4B0082", "#FFFFF0", "#F0E68C", "#E6E6FA", "#FFF0F5", "#7CFC00", "#FFFACD", "#ADD8E6", "#F08080", "#E0FFFF", "#FAFAD2", "#D3D3D3", "#90EE90", "#FFB6C1", "#FFA07A", "#20B2AA", "#87CEFA", "#778899", "#B0C4DE", "#FFFFE0", "#00FF00", "#32CD32", "#FAF0E6", "#800000", "#66CDAA", "#0000CD", "#BA55D3", "#9370DB", "#3CB371", "#7B68EE", "#00FA9A", "#48D1CC", "#C71585", "#191970", "#F5FFFA", "#FFE4E1", "#FFE4B5", "#FFDEAD", "#000080", "#FDF5E6", "#808000", "#6B8E23", "#FFA500", "#FF4500", "#DA70D6", "#EEE8AA", "#98FB98", "#AFEEEE", "#DB7093", "#FFEFD5", "#FFDAB9", "#CD853F", "#FFC0CB", "#DDA0DD", "#B0E0E6", "#800080", "#663399", "#FF0000", "#BC8F8F", "#4169E1", "#8B4513", "#FA8072", "#F4A460", "#2E8B57", "#FFF5EE", "#A0522D", "#C0C0C0", "#87CEEB", "#6A5ACD", "#708090", "#FFFAFA", "#00FF7F", "#4682B4", "#D2B48C", "#008080", "#D8BFD8", "#FF6347", "#40E0D0", "#EE82EE", "#F5DEB3", "#FFFFFF", "#F5F5F5", "#FFFF00", "#9ACD32"];
var BGCOR = MCor[NCor];

Mdiv.style.width = "40%";
Mdiv.style.top = "35%";
Mdiv.style.right = "30%";

document.getElementById('DIV00').style.display='none';
document.getElementById('DIV01').style.display='none';p03
document.getElementById('DIV02').style.display='none';
document.getElementById("p03").innerHTML = "<hr><p>ACABOU!!!<p><hr>";
document.getElementById('game').style.display='block';
document.getElementById("dtfim").innerHTML = new Date().getTime();
document.getElementById("dtres").innerHTML = (new Date().getTime() - DTINI)/1000+" Seg";
clearInterval(x);
//Mdiv.style.backgroundColor = "red";
document.body.style.backgroundColor = BGCOR;}
}, 1);}
}

function NEW_GAME() {
document.getElementById("fixedT").style.width = "18%";
document.getElementById("fixedT").style.top = "0.25%";
document.getElementById("fixedT").style.right = "41%";
document.getElementById("fixedT").style.height = "auto";
document.body.style.backgroundColor = "WHITE";
//document.getElementById('TLC').innerHTML = 3;
document.getElementById('DIV01').style.display='none';
var LIMPAR = document.getElementById("FieldseTForm0");
while (LIMPAR.hasChildNodes()) {
LIMPAR.removeChild(LIMPAR.lastChild);
}
ClearForm();
CountDown()
}

</script>


<body onload="INICIAL()">
<div class="fixedT" id="fixedT" style="text-align:center"><h1 id="p03"></h1></div>

<div id="mySidenav" class="sidenav">
<br><br>
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">[×] FECHAR</a><br>
<form id="cores" class="style2" action="">
<fieldset id="fldcores">
<legend>Alterar a Cor:</legend>
<input type="radio" name="TIPO" value="FUNDO">FUNDO<br>
<input type="radio" name="TIPO" value="FONTE">FONTE<br>
<br>
<input type="color" id="xyz" onchange="MyColor()" value="#FFFF00" style="width:75%;height:25px;">
</fieldset>
</form>
<br>
<div id="CONFIG">
<p style="text-align: center";>Configurações:</p>
<form id="sinais" class="style2" action="">
<fieldset id="fldsignals">
<legend>Operações:</legend>
<input type="radio" name="OPERMAT" onclick="PegaSignal(this.value)" value="2">[+ -]<br>
<input type="radio" name="OPERMAT" onclick="PegaSignal(this.value)" value="4">[+ - / *]<br>
<input type="radio" name="OPERMAT" onclick="PegaSignal(this.value)" value="6">[+ - / * X² &#8730;²]<br>
</fieldset>
</form>
<br>
<form id="tempo" class="style2" action="">
<fieldset>
<legend>Duração:</legend>
<input type="radio" name="time" onclick="PreCountDown(this.value)" value="1">01 Minuto<br>
<input type="radio" name="time" onclick="PreCountDown(this.value)" value="2">02 Minutos<br>
<input type="radio" name="time" onclick="PreCountDown(this.value)" value="3">03 Minutos<br>
<input type="radio" name="time" onclick="PreCountDown(this.value)" value="4">04 Minutos<br>
<input type="radio" name="time" onclick="PreCountDown(this.value)" value="5">05 Minutos<br>
</fieldset>
</form>
<p>
<button class="button00" onclick="INICIAL(), closeNav()">OK</button>
</div>
</div>

<div class="fixedTL" style="text-align:left";>
<span style="font-size:22px;cursor:pointer" onclick="openNav()"><b>&#9776; MENU</b></span>
</div>

<div class="fixedTR">
<span id="game" style="font-size:22px;cursor:pointer;display:none" onclick="NEW_GAME()"><b>[+TEMPO]</b></span>
</div>

<DIV id="DIVPT" align="center">
<h1 id="h1000"></h1>
</div>

<div id="DIV00" align="center">
<hr>
<form id="form0" action="" class="style1" name="pergunta">
<fieldset id="FieldseTForm0">
<legend></legend>
</fieldset>
</form>
<hr>
<!-- "ARMAZENAMENTO DE VARIÁVEIS" -->
<p id="sgn" style="display:none"></p> <!-- SINAL DA OPERAÇÃO MATEMÁTICA -->
<p id="PTS" style="display:none">0</p> <!-- PONTOS ACUMULADOS -->
<p id="CNT" style="display:none">0</p> <!-- CONTADOR DE FASE -->
<p id="C00" style="display:none">0</p> <!-- NUM 01 DA OPERAÇÃO -->
<p id="C01" style="display:none">0</p> <!-- NUM 02 DA OPERAÇÃO -->
<p id="NMX" style="display:none">0</p> <!-- CONTADOR DE FASE + 10, PONTOS POR RODADA-->
<p id="TLC" style="display:none">3</p> <!-- CONTADOR REGRESSIVO DO TIMER -->
<p id="CDT" style="display:none"></p> <!-- TEMPO DO JOGO-->
<p id="SIG" style="display:none"></p> <!--DEFINE SE TERÁ 2, 4 OU 6 OPERAÇÕES MATEMÁTICAS.-->
<!-- "ARMAZENAMENTO DE VARIÁVEIS" -->
</div>

<div id="DIV01" align="center">
<h1 id="h1001">RESULTADO:<hr></h1>
<form id="form1" action="" class="style1" name="resposta">
<fieldset id="FieldseTForm1">
<legend></legend>
<input type="number" id="vl02" size="8" min="-100" step="0.01" value="" onfocus="focusFunction()" onblur="PEGA_VAR()">
</fieldset>
</form>
<p id="p02"><hr>Informe o RESULTADO e PRESSIONE <TAB> para prosseguir.<br><font size="3.75em" color="#F00"><b>Use duas casas decimais com arredondamento.</b></font>
</div>

<div id="DIV02" align="center">
<h1 id="h1002" style="display:none">CORREÇãO:</h1>
<p id="p00"></p>
<button class="button" onclick="ClearForm()">CONTINUAR</button>
</div>

<div id="DIV03" align="center">
<h1 id="h1003"><hr>MATEMÁTICA PARA CRIANÇAS.</p>INICIANDO EM 3 SEGUNDO(s).<hr></h1>
</div>

<div id="DIVTM" align="center">
<h1 id="w00"></h1>
</div>

<div id="DIVSW" align="center">
<h1 id="w01"></h1>
<h1 id="w02"></h1>
</div>
<br>
<p id="dtini" style="display:none"></p>
<p id="dtfim" style="display:none"></p>
<p id="dtres" style="display:none"></p>

<div class="fixedB">
<font size="2" color="#000"><b>#  Marcelo Oliver -  Matemática para crianças  #</b></font>
</div>
</body>
</html>


Sim , é possível fazer em shellScript.
Segue o 'comando', para checagem da integridade do arquivo:

md5="89757957a4a77c2c211b2141485cc2e0"
[[ $(md5sum MAT-VOL.html|awk '{print $1}') = "$md5" ]] && echo "Código Okay" || echo "CóDIGO Not Okay"

Onde, MAT-VOL.html, é o nome do arquivo.
Att.:
Marcelo Oliver


9. Re: Dúvida sobre Shell Script

Perfil removido
removido

(usa Nenhuma)

Enviado em 12/10/2018 - 09:39h

msoliver escreveu:

b3f7 escreveu:

msoliver escreveu:

b3f7 escreveu:

Olá, queria saber se este fórum serve apenas para problemas relacionados ao Linux ou eu poderia pedir a ajuda de vcs com algo que me surgiu ultimamente. Vcs me ajudariam a criar um shell script pra rodar no terminal do linux e se possível no power shell do windows também? Como eu atualmente não tenho os conhecimentos necessários para prosseguir sozinho queria pedir (implorar!) por sua atenção. Eu tenho a ideia completa só preciso de assessoramento. Será um desafio que lhes dará mais conhecimento, eu espero. Posso deixar meu whats ou email aqui?



Boa noite.
Poste o que precisa para que possamos te ajudar...

Att.:
Marcelo Oliver


Marcelo, obrigado pela atenção.
Eu uma vez tava editando um código .bat do Windows e achei muito legal mas percebi que era limitado.
No Linux eu percebi que os scripts terminados em .sh eram, aparentemente, mais complexos e por isso eu quero ver se consigo criar um "produto" que é o meu objetivo final. Preciso saber se é possível usar algum código que gere aleatoriedade em perguntas bem básicas de aritmética, assim eu poderei, a partir de um código original, copiá-lo e modificá-lo para se passar por um programa para "ajudar crianças a se interessarem pela matemática através de um terminal". Acho que outras linguagens de programação seriam mais complexas e aprofundadas. Preciso de algo simples, nem de interface gráfica eu preciso. Minha ideia é a seguinte: Eu crio o corpo genérico de uma pergunta e o código gera aleatoriamente o cálculo, a resposta, as alternativas e uma saída para caso a entrada seja correta ou errada. Vou detalhar: digamos que o corpo genérico da pergunta seja "Agora vamos brincar de acertar a multiplicação (aqui eu posso mudar e colocar adição, subtração, divisão) no menor tempo que você conseguir!", nessa parte o código faz multiplicação e todos os detalhes que eu já passei. Viram que agora tem temporizador?! Dá pra fazer isso em script?


Boa noite b3f7.
Tenho algo parecido em JavaScript...
No MENU, escolha o tipo de operação.... e o tempo de duração... ai é só brincar....
Fiz já tem um tempo.... para a criançada da família....
Interessa??
Segue o código....
Salve como html.
<!DOCTYPE html>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<!-- Marcelo Oliver | ABRIL/2017-->
<html>
<head>
<title> -- MATEMáTICA V.10 -- </title>
<style>

#CONFIG {
display: block;
margin: auto;
width: 180px;
left:1%;
border: 1px solid #FF0;
padding: 2.5px;
border-radius: 6px;
}

#DIVPT {
display: none;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
left:1%;
right: 1%;
top: 10%;
padding: 2.5px;
border: 3px ridge #FF0;
border-radius: 8px;
}

#DIVTM {
display: none;
position: fixed;
margin: auto;
width: 7.5%;
max-height: 520px;
right: 0.5%;
top: 5%;
padding: 2.5px;
border: 3px ridge #000;
border-radius: 8px;
}

#DIVSW {
display: none;
position: fixed;
margin: auto;
width: 7.5%;
max-height: 520px;
right: 0.5%;
top: 15%;
padding: 2.5px;
border: 3px ridge #000;
border-radius: 8px;
}

#DIV00 {
display: none;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
right: 1%;
left:1%;
top: 25%;
padding-top: 2.5px;
padding-right: 2.5px;
padding-bottom: 2.5px;
padding-left: 2.5px;
border: 2.5px ridge black;
border-radius: 8px;
}

#DIV01 {
display: none;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
right: 1%;
left:1%;
bottom: 20%;
padding: 2.5px;
border: 2.5px ridge black;
border-radius: 8px;
}

#DIV02 {
display: none;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
right: 1%;
left:1%;
top: 24%;
padding: 2.5px;
border: 2.5px ridge black;
border-radius: 8px;
}

#DIV03 {
display: block;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
right: 1%;
left:1%;
top: 15%;
padding: 25px;
border: 2.5px ridge black;
border-radius: 8px;
}

#DIVALERTA {
display: none;
position: fixed;
margin: auto;
width: 50%;
max-height: 520px;
right: 1%;
left:1%;
top: 30%;
padding: 2.5px;
border: 2.5px ridge black;
border-radius: 8px;
}

div.top {
margin: auto;
top: 1.5%;
width: 50%;
right: 25%;
background-color: #FFF;
border: 2.5px ridge black;
padding: 2px;
border-radius: 8px;
}

input[type=number]{
font-size:1.8em;
width:4.5em;
padding-top: 2.5px;
padding-right: 2.5px;
padding-bottom: 2.5px;
padding-left: 2.5px;
margin:1;
border:1px solid #ddd;
border-radius:5px;
text-align:center;
}

input[type=text]{
font-size:1.8em;
width:4.5em;
padding-top: 2.5px;
padding-right: 2.5px;
padding-bottom: 2.5px;
padding-left: 2.5px;
margin:1;
border:1px solid #ddd;
border-radius:5px;
text-align:center;
}

input[type=color]{
font-size:1.4em;
width:4em;
padding-top: 2px;
padding-right: 2px;
padding-bottom: 2px;
padding-left: 2px;
border:5px solid #000;
border-radius:5px;
}

form.style1 fieldset {
align: center;
margin: auto;
border:1px solid black;
border-radius: 5px;
padding-top: 7.5px;
padding-right: 2.5px;
padding-bottom: 7.5px;
padding-left: 2.5px;
width: 80%;
}

form.style1 legend {
align: center;
padding: 0.2em 0.5em;
border:1px solid black;
border-radius: 5px;
color:black;
font-size:0%;
text-align:right;
}

form.style1 input {
border:0.5px ridge #000;
border-radius: 8px;
}

form.style2 fieldset {
align: center;
margin: auto;
border:1px solid #FF0;
border-radius: 5px;
padding-top: 7.5px;
padding-right: 2.5px;
padding-bottom: 7.5px;
padding-left: 2.5px;
width: 90%;
}

div.fixedB {
position: fixed;
margin: auto;
text-align: center;
bottom: 0%;
width: 50%;
right: 25%;
background-color: #FFF;
border: 1px solid #000;
padding: 0.5px;
border-radius: 6px;
}

div.fixedT {
background-color: #FFF;
margin: auto;
position: fixed;
width: 18%;
text-align: center;
top: 0.25%;
right: 41%;
border: 0px ridge #000;
padding: 0px;
border-radius: 8px;

}

#w00 {
line-height: 0.125;
color: white;
text-shadow: 2px 2px 4px #000;
text-align: center;
}

#w01 {
line-height: 0.125;
color: #FF0;
text-shadow: 2px 2px 4px #000;
text-align: center;
}

#w02 {
line-height: 0.125;
color: #00F;
text-shadow: 2px 2px 4px #000;
text-align: center;
}

#p00 {
line-height: 0.6125;
letter-spacing: 0.25px;
font-size: 3.6em;
text-shadow: 2px 2px 4px #000;
}

#p01 {
line-height: 0.8;
letter-spacing: 0.25px;
font-size: 28px;
text-shadow: 2px 2px 4px #00F;
}

#p03 {
text-align: center;
line-height: 0;
letter-spacing: 0.25px;
}

#h1000 {
line-height: 0.125;
color: white;
text-shadow: 1px 2px 4px #000;
text-align: center;
}

#h1001 {
line-height: 0.125;
color: yellow;
text-shadow: 1px 2px 4px #000;
text-align: center;
}

#h1002 {
line-height: 0.125;
color: blue;
text-shadow: 1px 2px 4px #000;
text-align: center;
}

#h1003 {
line-height: 1.25;
color: #00F;
text-shadow: 2px 2px 6px #00F;
}

.button00 {
background-color: #FF0;
border: 1.25px solid #000;
border-radius: 4px;
color: #000;
padding: 2.5px 5px;
text-align: center;
font-size: 14px;
cursor: pointer;
}

.button {
background-color: #FF0;
border: 1.25px solid #000;
border-radius: 6px;
color: #000;
padding: 2.5px 5px;
text-align: center;
text-decoration: none;
outline: none;
display: inline-block;
font-size: 18px;
margin: 4px 2px;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.5s;
cursor: pointer;
box-shadow: 0 0px #FFF;
}

.button:hover {
background-color: #6666FF;
}

.button:active {
background-color: #555555;
box-shadow: 0 5px #666;
transform: translateY(5px);0.1
}

hr {
border-style: inset;
border-width: 2px;
color:yellow;
width: 90%;
}

div.fixedTL {
position: fixed;
margin: auto;
text-align: left;
top: 2%;
width: 8%;
left: 0.5%;
height: 25px;
}

div.fixedTR {
position: fixed;
margin: auto;
text-align: right;
top: 2%;
width: 12%;
right: 0.5%;
height: 25px;
}

.sidenav {
width: 0%;
position: fixed;
z-index: 1;
top: 2%;
left: 0.5%;
color: #818181;
background-color: #000;
overflow-x: hidden;
transition: 0.25s;
}

.sidenav a {
padding: 2px 2px 2px 16px;
text-decoration: none;
font-size: 12px;
color: #818181;
display: block;
transition: 0.3s
}

.sidenav a:hover, .offcanvas a:focus{
color: #f1f1f1;
}

.sidenav .closebtn {
position: absolute;
top: 0;
right: 2.5px;
font-size: 14px;
margin-left: 0px;
}

@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
}

</style>
</head>

<script>
/*DEFINE VARS*/
var myVar, TEMPODUR=0, QTSIG=0;
/*DEFINE VARS [NNSIG=6] */

function INICIAL() {
document.getElementById("mySidenav").style.height = (screen.height - 170)+"px";
document.getElementById('cores').reset();
document.getElementById('sinais').reset();
document.getElementById('tempo').reset();
TEMPODUR = document.getElementById("CDT").innerHTML;
QTSIG = document.getElementById("SIG").innerHTML;
if(TEMPODUR==0 || QTSIG==0){
document.getElementById("h1003").innerHTML = "<hr>MATEMÁTICA PARA CRIANÇAS.<hr>No MENU/Configurações<br>Defina as \"Operações\" e a \"Duração\".<br>CLIQUE [OK] para iniciar<hr>";}
else {document.getElementById("h1003").innerHTML = "<hr>INICIANDO EM 3 SEGUNDOS<hr>";
StartTimer();
document.getElementById('CONFIG').style.display='none';
}
}

function RELOAD() {
window.location.reload(true);
}

function addZero(y,n) {
while (y.toString().length < n) {
y = "0" + y;
}
return y;
}

function ClearForm() {
var LIMPAR = document.getElementById("FieldseTForm0");
while (LIMPAR.hasChildNodes()) {
LIMPAR.removeChild(LIMPAR.lastChild);
}
document.getElementById('DIV00').style.display='block';
document.getElementById('DIV01').style.display='block';
document.getElementById('DIV02').style.display='none';
document.getElementById('form1').reset();
GeraForm()
}

function GeraForm() {
document.getElementById('form1').reset();
//GERA OPERADOR
var n, NN, sgn="", ncp=2, NM=0, TIME=0;
var SIGNAL = ["+", "-", "/", "*", "P", "R" ]; /* X², &#8730;² 8730 221A */
var NNSIG = document.getElementById("SIG").innerHTML;
var N = Math.floor(Math.random() * NNSIG);
sgn = SIGNAL[N];
document.getElementById('sgn').innerHTML = sgn;

//GERA CONTADOR DE FASE/PTOS E ATUALIZA
var CNT = document.getElementById("CNT").innerHTML;
CNT = Number(CNT);
var COUNT = CNT + 1;
document.getElementById("CNT").innerHTML = COUNT;
var COUNT00 = addZero(COUNT, 2);

NM += COUNT+10;
document.getElementById("NMX").innerHTML = NM;

PTS = document.getElementById('PTS').innerHTML;
PTS = Number(PTS);
document.getElementById("h1000").innerHTML = "Fase: "+COUNT00+" # Pontos: " +PTS;

//GERA INPUTS (2 ou 1) resolve o sinal p/ P e R
if(sgn=="R" || sgn=="P"){var ncp = 1;}
for (n=0;n<ncp;n++) {
var x = document.createElement("input");
NN = Math.floor((Math.random() * NM) + 1);
//DEFINE SINAL PARA "P", "R", ETC
if(n>0){document.getElementById("FieldseTForm0").appendChild(document.createTextNode(" "+sgn+" "));}
if(sgn == "R"){SGN = "&#8730;"+NN;}
if(sgn == "P"){SGN = NN+"²";}

x.type = "text";
if(ncp==2){x.value = NN;}
else if(ncp==1){x.value = SGN;}
document.getElementById("C0"+n).innerHTML = NN;
x.readOnly = "readOnly";
x.id = "vl0"+n;
x.step = "0.01";
x.min = "0";
x.size = "6";
document.getElementById("FieldseTForm0").appendChild(x);
}
}

function PEGA_VAR() {
var VL0, VL1, VL2, TTL, sgn, PTS, NP=0, COUNT=0;
COUNT = document.getElementById("CNT").innerHTML;
sgn = document.getElementById('sgn').innerHTML;
if(sgn == "R" || sgn == "P"){VL0 = Number(document.getElementById("C00").innerHTML);}
else{
VL0 = Number(document.getElementById("C00").innerHTML);
VL1 = Number(document.getElementById("C01").innerHTML);
}

VL2 = Number(document.getElementById('vl02').value);
PTS = document.getElementById('PTS').innerHTML;
PTS = Number(PTS);

COUNT = Number(COUNT)
COUNT00 = addZero(COUNT, 2);

if(sgn=="P"){var TTL = Math.pow(VL0, 2);}
else if(sgn=="R"){var TTL = Math.sqrt(VL0);}
else{var TTL = eval(VL0+sgn+VL1);}


var R = /\.[0-9]+/.test(TTL); //VERIFICA SE TEM PONTO NO RESULTADO, SE TIVER, FIXA COM DUAS CASA DECIMAIS E ARREDONDA
if(Number(R) == "1"){TTL = Number(TTL).toFixed(2);}

document.getElementById('DIV00').style.display='none';
document.getElementById('DIV01').style.display='none';
document.getElementById('DIV02').style.display='block';

NP = document.getElementById('NMX').innerHTML;
NP = Number(NP);

if(TTL == VL2){PTS = PTS + NP;
document.getElementById("p00").innerHTML = "<font color=#0F0><b> &#9786; Resposta &#9745;"+"</b>"+"</font>";}

else{PTS = PTS - NP;
document.getElementById("p00").innerHTML = "<font color=#F00><b> &#9785; Resposta &#9746;</b></font><hr><font size=10px> O &#9745; é: "+TTL+"<hr></font>";}

document.getElementById("h1000").innerHTML = "Fase: "+COUNT00+" # Pontos: " + PTS;
document.getElementById('PTS').innerHTML = PTS;
}

function focusFunction() {
document.getElementById("vl02").style.background = "yellow";
}

function StartTimer() {
myVar = setInterval(timer, 1000);
}

function timer() {
t = document.getElementById("TLC").innerHTML;
var t = t - 1;
document.getElementById("TLC").innerHTML = t;
document.getElementById("h1003").innerHTML = "<hr>INICIANDO EM " + t + " SEGUNDO(s).<hr>";
if(t==0){
clearInterval(myVar);
CountDown()
document.getElementById("dtini").innerHTML = new Date().getTime();
document.getElementById('DIVPT').style.display='block';
document.getElementById('DIV00').style.display='block';
document.getElementById('DIV01').style.display='block';
document.getElementById('DIV03').style.display='none';
GeraForm()
}
}

function openNav() {
document.getElementById("mySidenav").style.width = "200px";
}

function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}

function MyColor() {
var COR = document.getElementById("xyz").value;
var TIPO = document.forms[0];
var i, TPCOR;
for (i = 0;i<TIPO.length;i++) {
if (TIPO[i].checked) {TPCOR = TIPO[i].value;}
}
if(TPCOR=="FUNDO") {document.body.style.backgroundColor = COR;}
else if(TPCOR=="FONTE") {document.body.style.color = COR;}
}

function PegaSignal(QTSIG) {
document.getElementById("SIG").innerHTML = QTSIG;
}

function PreCountDown(TEMPODUR) {
document.getElementById("CDT").innerHTML = TEMPODUR;
}

function CountDown() {
TEMPODUR = document.getElementById("CDT").innerHTML;
document.getElementById("dtini").innerHTML = new Date().getTime(); // milisegundos
var DTINI = document.getElementById("dtini").innerHTML;
var datafim = (TEMPODUR * 60 * 1000) + new Date().getTime();
var countDownDate = new Date(datafim).getTime();
var Mdiv = document.getElementById("fixedT");

if(countDownDate > new Date().getTime()) {
Mdiv.style.backgroundColor = "#00FF55";
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
var Min = addZero(Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)), 2);
var Sec = addZero(Math.floor((distance % (1000 * 60)) / 1000), 2);
var Mse = addZero(Math.floor(distance % 1000), 3);

if (distance >= 0) {document.getElementById("p03").innerHTML = Min + ":" + Sec + ":" + Mse;}

else {
var NCor = Math.floor(Math.random() * 139);
var MCor = ["#F0F8FF", "#FAEBD7", "#00FFFF", "#7FFFD4", "#F0FFFF", "#F5F5DC", "#FFE4C4", "#000000", "#FFEBCD", "#0000FF", "#8A2BE2", "#A52A2A", "#DEB887", "#5F9EA0", "#7FFF00", "#D2691E", "#FF7F50", "#6495ED", "#FFF8DC", "#DC143C", "#00008B", "#008B8B", "#B8860B", "#A9A9A9", "#006400", "#BDB76B", "#8B008B", "#556B2F", "#FF8C00", "#9932CC", "#8B0000", "#E9967A", "#8FBC8F", "#483D8B", "#2F4F4F", "#00CED1", "#9400D3", "#FF1493", "#00BFFF", "#696969", "#1E90FF", "#B22222", "#FFFAF0", "#228B22", "#FF00FF", "#DCDCDC", "#F8F8FF", "#FFD700", "#DAA520", "#808080", "#008000", "#ADFF2F", "#F0FFF0", "#FF69B4", "#CD5C5C", "#4B0082", "#FFFFF0", "#F0E68C", "#E6E6FA", "#FFF0F5", "#7CFC00", "#FFFACD", "#ADD8E6", "#F08080", "#E0FFFF", "#FAFAD2", "#D3D3D3", "#90EE90", "#FFB6C1", "#FFA07A", "#20B2AA", "#87CEFA", "#778899", "#B0C4DE", "#FFFFE0", "#00FF00", "#32CD32", "#FAF0E6", "#800000", "#66CDAA", "#0000CD", "#BA55D3", "#9370DB", "#3CB371", "#7B68EE", "#00FA9A", "#48D1CC", "#C71585", "#191970", "#F5FFFA", "#FFE4E1", "#FFE4B5", "#FFDEAD", "#000080", "#FDF5E6", "#808000", "#6B8E23", "#FFA500", "#FF4500", "#DA70D6", "#EEE8AA", "#98FB98", "#AFEEEE", "#DB7093", "#FFEFD5", "#FFDAB9", "#CD853F", "#FFC0CB", "#DDA0DD", "#B0E0E6", "#800080", "#663399", "#FF0000", "#BC8F8F", "#4169E1", "#8B4513", "#FA8072", "#F4A460", "#2E8B57", "#FFF5EE", "#A0522D", "#C0C0C0", "#87CEEB", "#6A5ACD", "#708090", "#FFFAFA", "#00FF7F", "#4682B4", "#D2B48C", "#008080", "#D8BFD8", "#FF6347", "#40E0D0", "#EE82EE", "#F5DEB3", "#FFFFFF", "#F5F5F5", "#FFFF00", "#9ACD32"];
var BGCOR = MCor[NCor];

Mdiv.style.width = "40%";
Mdiv.style.top = "35%";
Mdiv.style.right = "30%";

document.getElementById('DIV00').style.display='none';
document.getElementById('DIV01').style.display='none';p03
document.getElementById('DIV02').style.display='none';
document.getElementById("p03").innerHTML = "<hr><p>ACABOU!!!<p><hr>";
document.getElementById('game').style.display='block';
document.getElementById("dtfim").innerHTML = new Date().getTime();
document.getElementById("dtres").innerHTML = (new Date().getTime() - DTINI)/1000+" Seg";
clearInterval(x);
//Mdiv.style.backgroundColor = "red";
document.body.style.backgroundColor = BGCOR;}
}, 1);}
}

function NEW_GAME() {
document.getElementById("fixedT").style.width = "18%";
document.getElementById("fixedT").style.top = "0.25%";
document.getElementById("fixedT").style.right = "41%";
document.getElementById("fixedT").style.height = "auto";
document.body.style.backgroundColor = "WHITE";
//document.getElementById('TLC').innerHTML = 3;
document.getElementById('DIV01').style.display='none';
var LIMPAR = document.getElementById("FieldseTForm0");
while (LIMPAR.hasChildNodes()) {
LIMPAR.removeChild(LIMPAR.lastChild);
}
ClearForm();
CountDown()
}

</script>


<body onload="INICIAL()">
<div class="fixedT" id="fixedT" style="text-align:center"><h1 id="p03"></h1></div>

<div id="mySidenav" class="sidenav">
<br><br>
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">[×] FECHAR</a><br>
<form id="cores" class="style2" action="">
<fieldset id="fldcores">
<legend>Alterar a Cor:</legend>
<input type="radio" name="TIPO" value="FUNDO">FUNDO<br>
<input type="radio" name="TIPO" value="FONTE">FONTE<br>
<br>
<input type="color" id="xyz" onchange="MyColor()" value="#FFFF00" style="width:75%;height:25px;">
</fieldset>
</form>
<br>
<div id="CONFIG">
<p style="text-align: center";>Configurações:</p>
<form id="sinais" class="style2" action="">
<fieldset id="fldsignals">
<legend>Operações:</legend>
<input type="radio" name="OPERMAT" onclick="PegaSignal(this.value)" value="2">[+ -]<br>
<input type="radio" name="OPERMAT" onclick="PegaSignal(this.value)" value="4">[+ - / *]<br>
<input type="radio" name="OPERMAT" onclick="PegaSignal(this.value)" value="6">[+ - / * X² &#8730;²]<br>
</fieldset>
</form>
<br>
<form id="tempo" class="style2" action="">
<fieldset>
<legend>Duração:</legend>
<input type="radio" name="time" onclick="PreCountDown(this.value)" value="1">01 Minuto<br>
<input type="radio" name="time" onclick="PreCountDown(this.value)" value="2">02 Minutos<br>
<input type="radio" name="time" onclick="PreCountDown(this.value)" value="3">03 Minutos<br>
<input type="radio" name="time" onclick="PreCountDown(this.value)" value="4">04 Minutos<br>
<input type="radio" name="time" onclick="PreCountDown(this.value)" value="5">05 Minutos<br>
</fieldset>
</form>
<p>
<button class="button00" onclick="INICIAL(), closeNav()">OK</button>
</div>
</div>

<div class="fixedTL" style="text-align:left";>
<span style="font-size:22px;cursor:pointer" onclick="openNav()"><b>&#9776; MENU</b></span>
</div>

<div class="fixedTR">
<span id="game" style="font-size:22px;cursor:pointer;display:none" onclick="NEW_GAME()"><b>[+TEMPO]</b></span>
</div>

<DIV id="DIVPT" align="center">
<h1 id="h1000"></h1>
</div>

<div id="DIV00" align="center">
<hr>
<form id="form0" action="" class="style1" name="pergunta">
<fieldset id="FieldseTForm0">
<legend></legend>
</fieldset>
</form>
<hr>
<!-- "ARMAZENAMENTO DE VARIÁVEIS" -->
<p id="sgn" style="display:none"></p> <!-- SINAL DA OPERAÇÃO MATEMÁTICA -->
<p id="PTS" style="display:none">0</p> <!-- PONTOS ACUMULADOS -->
<p id="CNT" style="display:none">0</p> <!-- CONTADOR DE FASE -->
<p id="C00" style="display:none">0</p> <!-- NUM 01 DA OPERAÇÃO -->
<p id="C01" style="display:none">0</p> <!-- NUM 02 DA OPERAÇÃO -->
<p id="NMX" style="display:none">0</p> <!-- CONTADOR DE FASE + 10, PONTOS POR RODADA-->
<p id="TLC" style="display:none">3</p> <!-- CONTADOR REGRESSIVO DO TIMER -->
<p id="CDT" style="display:none"></p> <!-- TEMPO DO JOGO-->
<p id="SIG" style="display:none"></p> <!--DEFINE SE TERÁ 2, 4 OU 6 OPERAÇÕES MATEMÁTICAS.-->
<!-- "ARMAZENAMENTO DE VARIÁVEIS" -->
</div>

<div id="DIV01" align="center">
<h1 id="h1001">RESULTADO:<hr></h1>
<form id="form1" action="" class="style1" name="resposta">
<fieldset id="FieldseTForm1">
<legend></legend>
<input type="number" id="vl02" size="8" min="-100" step="0.01" value="" onfocus="focusFunction()" onblur="PEGA_VAR()">
</fieldset>
</form>
<p id="p02"><hr>Informe o RESULTADO e PRESSIONE <TAB> para prosseguir.<br><font size="3.75em" color="#F00"><b>Use duas casas decimais com arredondamento.</b></font>
</div>

<div id="DIV02" align="center">
<h1 id="h1002" style="display:none">CORREÇãO:</h1>
<p id="p00"></p>
<button class="button" onclick="ClearForm()">CONTINUAR</button>
</div>

<div id="DIV03" align="center">
<h1 id="h1003"><hr>MATEMÁTICA PARA CRIANÇAS.</p>INICIANDO EM 3 SEGUNDO(s).<hr></h1>
</div>

<div id="DIVTM" align="center">
<h1 id="w00"></h1>
</div>

<div id="DIVSW" align="center">
<h1 id="w01"></h1>
<h1 id="w02"></h1>
</div>
<br>
<p id="dtini" style="display:none"></p>
<p id="dtfim" style="display:none"></p>
<p id="dtres" style="display:none"></p>

<div class="fixedB">
<font size="2" color="#000"><b>#  Marcelo Oliver -  Matemática para crianças  #</b></font>
</div>
</body>
</html>


Sim , é possível fazer em shellScript.
Segue o 'comando', para checagem da integridade do arquivo:

md5="89757957a4a77c2c211b2141485cc2e0"
[[ $(md5sum MAT-VOL.html|awk '{print $1}') = "$md5" ]] && echo "Código Okay" || echo "CóDIGO Not Okay"

Onde, MAT-VOL.html, é o nome do arquivo.
Att.:
Marcelo Oliver


Me interessa sim! Vou precisar de um tempinho pra dar um retorno aqui. Obrigado novamente.



10. Re: Dúvida sobre Shell Script

Perfil removido
removido

(usa Nenhuma)

Enviado em 12/10/2018 - 09:48h

Marcelo, vc tem tempo pra me ajudar a mexer no teu código? Eu inseri a resposta mas voltou ao início sem dar nenhum retorno e poderíamos enxugar algumas coisa, por exemplo, retirar aquele botão de menu e deixar fundo e fonte, por exemplo, definidos. Lembrando, eu não consigo fazer isso sem bugar todo o código! Precisaria de um tutor.


11. Re: Dúvida sobre Shell Script

Perfil removido
removido

(usa Nenhuma)

Enviado em 12/10/2018 - 09:50h

É possível transformar esse html em executável? JavaScrip é a mesma coisa que Java? Pode ser multiplataforma?


12. Re: Dúvida sobre Shell Script

Perfil removido
removido

(usa Nenhuma)

Enviado em 12/10/2018 - 09:59h

Poderíamos também limitar a respostas à números inteiros (Z).



01 02



Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts