Jump to content
LegendKiller

Script bash - problema

Recommended Posts

Posted

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

 

 

Posted

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

 

  • Like 2
  • Upvote 2

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...