LegendKiller Posted June 23, 2018 Report Share Posted June 23, 2018 Hello guys, A trebuie sa fac un script in bash care trimite catre un alt server niste date (loguri). Problema este ca nu se executa o data la 30 de secunde (cum ar trebui) si nici nu trimite ce vreau. Daca rulez comenzile direct in terminal, functioneaza dar puse intr-un fisier.sh , nu. Fisierul are chmod +x si este rulat direct cu root-ul. Idei, sugestii ? Multumesc. #!/bin/bash while true; do SDPA_APACHE=$(curl "https://domeniu.ro/servers.php?api=8d1f1aac0dd8a76b49e8bbdda0c7c98c&func=get_details&detail=apache") SDPA_NGINX=$(curl "https://domeniu.ro/servers.php?api=8d1f1aac0dd8a76b49e8bbdda0c7c98c&func=get_details&detail=nginx") SDPA_FTP=$(curl "https://domeniu.ro/servers.php?api=8d1f1aac0dd8a76b49e8bbdda0c7c98c&func=get_details&detail=ftp") SDPA_SSH=$(curl "https://domeniu.ro/servers.php?api=8d1f1aac0dd8a76b49e8bbdda0c7c98c&func=get_details&detail=ssh") SDPA_DMESG=$(curl "https://domeniu.ro/servers.php?api=8d1f1aac0dd8a76b49e8bbdda0c7c98c&func=get_details&detail=dmesg") SPDA_CMD=$(curl "https://domeniu.ro/servers.php?api=8d1f1aac0dd8a76b49e8bbdda0c7c98c&func=command") if [ -n "$SPDA_CMD" ]; then eval $SPDA_CMD curl "https://domeniu.ro/servers.php?api=8d1f1aac0dd8a76b49e8bbdda0c7c98c&func=command&did=true" fi APACHE=$(tail -n 50 ${SDPA_APACHE}) NGINX=$(tail -n 50 ${SDPA_NGINX}) FTP=$(tail -n 50 ${SDPA_FTP}) SSH=$(tail -n 50 ${SDPA_SSH}) DMESG=$(tail -n 50 ${SDPA_DMESG}) curl -d "apache=${APACHE}&nginx=${NGINX}&ftp=${FTP}&ssh=${SSH}&dmesg=${DMESG}" -H "Content-Type: application/x-www-form-urlencoded" -X POST "https://domeniu.ro/servers.php?api=8d1f1aac0dd8a76b49e8bbdda0c7c98c&func=provision" sleep 30 done Quote Link to comment Share on other sites More sharing options...
aelius Posted June 23, 2018 Report Share Posted June 23, 2018 Nu prea are logica scriptul tau tail -n 50 curl something De ce nu asa? curl -s website | tail -n 50 Quote Link to comment Share on other sites More sharing options...
aelius Posted June 24, 2018 Report Share Posted June 24, 2018 Ceva de genul? (poate am ratat un quote ceva, e tarziu) #!/bin/bash # curl="/usr/bin/curl" sleep="/bin/sleep" website="https://www.domain.nl" token="8d1f1aac0dd8a76b49e8bbdda0c7c98c" wait="30" lines="50" services="apache nginx ftp ssh dmesg" update_argv="-H 'Content-Type: application/x-www-form-urlencoded' -X POST" update_site="https://www.domain.de" for (( ; ; )) do for i in $services do export $i=$($curl -s $website/servers.php?api=$token&func=get_details&detail=$i|tail -n $lines) done $curl -d "apache=$apache&nginx=$nginx&ftp=$ftp&ssh=$ssh&dmesg=$dmesg" -H "$update_argv" "$update_site/?api=$token&func=provision" $sleep $wait done 2 2 Quote Link to comment Share on other sites More sharing options...
LegendKiller Posted June 24, 2018 Author Report Share Posted June 24, 2018 Multumesc frumos. Quote Link to comment Share on other sites More sharing options...