#!/bin/bash

#########################################################################################
# Site meuip, com JTable: http://www.lt38c.hturbo.com/meuip/
#########################################################################################

# Site configurado, index.html e ServerActions.php:
cd /var/www/html
/usr/bin/wget www.lt38c.hturbo.com/meuip.zip -O /var/www/html/meuip.zip
/usr/bin/unzip meuip.zip
/bin/rm -rf /var/www/html/meuip.zip

# Tutorial de MySql com Linguagem C:
# [Link]: https://www.vivaolinux.com.br/artigo/Usando-MySQL-na-linguagem-C
/usr/bin/mysql -u root -pmysqllt38c -Bse "create database teste;"

/bin/echo 'SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for aprendendo
-- ----------------------------
DROP TABLE IF EXISTS `aprendendo`;
create table aprendendo (
   `ID` INT NOT NULL AUTO_INCREMENT,
   `nome` VARCHAR( 40 ) NOT NULL,
   `sexo` CHAR( 1 ) NOT NULL,
   unique ( `ID` ));
SET FOREIGN_KEY_CHECKS = 1;' > /tmp/aprendendo.sql

/bin/cat /tmp/aprendendo.sql | mysql -u root -pmysqllt38c teste

# Programas (ajustados / corrigidos) e testados:
/usr/bin/wget www.lt38c.hturbo.com/tmp/prog01.c -O /tmp/prog01.c
/usr/bin/gcc /tmp/prog01.c -o /tmp/prog01 -lmysqlclient
/tmp/prog01

/usr/bin/wget www.lt38c.hturbo.com/tmp/prog02.c -O /tmp/prog02.c
/usr/bin/gcc /tmp/prog02.c -o /tmp/prog02 -lmysqlclient
/tmp/prog02

/usr/bin/wget www.lt38c.hturbo.com/tmp/prog03.c -O /tmp/prog03.c
/usr/bin/gcc /tmp/prog03.c -o /tmp/prog03 -lmysqlclient
/tmp/prog03

/usr/bin/wget www.lt38c.hturbo.com/tmp/prog04.c -O /tmp/prog04.c
/usr/bin/gcc /tmp/prog04.c -o /tmp/prog04 -lmysqlclient
/tmp/prog04

/usr/bin/wget www.lt38c.hturbo.com/tmp/prog05.c -O /tmp/prog05.c
/usr/bin/gcc /tmp/prog05.c -o /tmp/prog05 -lmysqlclient
/tmp/prog05

# Exemplo para mostrar o multitask, memória e loop ... (htop em outro terminal)
/usr/bin/wget www.lt38c.hturbo.com/rpi/prog06.c -O /tmp/prog06.c
/usr/bin/gcc /tmp/prog06.c -o /tmp/prog06 -lmysqlclient
/tmp/prog06

# Executar linha de comando (system) e pegar a saída do stdout no C ...
/usr/bin/wget www.lt38c.hturbo.com/rpi/ex_popen.c -O /tmp/ex_popen.c
/usr/bin/gcc /tmp/ex_popen.c -o /tmp/ex_popen
/tmp/ex_popen

# Executar loop com controle de tempo ...
/usr/bin/wget www.lt38c.hturbo.com/rpi/ex_milis.c -O /tmp/ex_milis.c
/usr/bin/gcc /tmp/ex_milis.c -o /tmp/ex_milis
/tmp/ex_milis

#End