Skripta za provjeru promjene sadrzaja direktorijuma

Teme koje se tiču programiranja

Moderator: Urednik

Post Reply

Stalni član
Stalni član
offline

Posts: 47
Joined: 23 Dec 2011, 00:25

Post Napisano: 19 Apr 2012, 12:13


Pozdrav,
Ovo sam u sklopu posla morao da odradim pa reko da stavim ovde moze valjati nekome
Ova skripta u sustini moze da se nakaci u cron pa da radi periodicno. Salje putem http tj post metode na neki sajt

Ovo se moze srediti da radi provjeru fajl sistema, sigurnosne provjere i sl.

Nije nesto sad extra al radi posao.

bash skripta:

Code: Select all

DIR_SOURCES="/test2"
TMP_FILE="t2"
OLD_RES_FILE="t1"
TMP_RES_FILE="raz"
DONT_L=test2b
T_URL="http://127.0.0.1/index2.php"

#creating list of files in dir
find $DIR_SOURCES > $TMP_FILE
#see what diff is betwen old and new list of dir | then we jump first line with awk
diff $OLD_RES_FILE $TMP_FILE |awk '{if (NR!=1) {print $2}}' > $TMP_RES_FILE

#removing old list of dir - we dont need we have diff and we have new one; then move new one to be old
rm $OLD_RES_FILE; cp $TMP_FILE $OLD_RES_FILE

#here we move dir and files that we dont need to check
sed "/$DONT_L/d" $TMP_RES_FILE > $TMP_FILE

#removing blank lines produced with diff
sed '/^$/d' $TMP_FILE > $TMP_RES_FILE

#Debug purpose
#cat $TMP_RES_FILE

while read inputline
do
  url="$(echo $inputline)"

  headers="$(wget -q --post-data="videos="$url $T_URL -O /dev/null)"

#  For debuggin purpose
#  echo "$url $headers"

  sleep 2
done < $TMP_RES_FILE



Stalni član
Stalni član
offline

Posts: 47
Joined: 23 Dec 2011, 00:25

Post Napisano: 19 Apr 2012, 17:14


Evo jos jedna skripta - ova gore ce biti doradjena i prepravljena - nasao sam joj manu :D
PRvo morate uraditi kopiranje kljuca na drugi server prema http://www.linuxproblem.org/art_9.html
generiste javni i tajni kljuc, gdje ce te javni kljuc poslati na server na kome pristupate.
Ovo dole je tajni kljuc koji nosite u skripti.
sad mozete izdati komandu :
./ssh_skripa ls
ili samo da pristupite serveru:
./ssh_skripta
ne zaboravite da uradite chmod 700 ssh_skripta
mozete je nositi na USB ili dodatno sifrovati :)

Code: Select all

#!/bin/bash
_me="${0##*/}"
_user="korisnickoime"
_port="22"
_server="nasserver.net"
_args="$@"
## Server name validation ##
host $_server &>/dev/null
[ $? -ne 0 ] && { echo "Server '$_server' not found. Set correct \$_server in $_me script."; exit 1; }
 
## Get in ##
ssh -i "${_me}" -p $_port ${_user}@${_server} "$_args"
exit

-----BEGIN RSA PRIVATE KEY-----
T8IOlya21PEYeqp0ypkpck2ynJ0lPkv0OU5M+bp5HD6KJ24PsZDdh3miwD8CAwEA
AQKCAgEAspAdayFNHub0z6GcBk07GXtRJhTPSJxqby1MgLdv2IW8+26fF5gOQhAw
oD3kfdji5K/7kvZEyLtUAuxC34uumwQEp+ct6uABO4WMbk/2aNIOxZ2WQI1PHuVO
MpfQL3CsjRdJs3rdmrLbPXqkboeV3qCoT5D4i64dyRisxn2zjGED4IyeZ59DA9K7
0yxurypqzR82gez2Asy4tLSfQpQFvyUte1XcOLqII+y0itjZOVN6gcUX0vO1q7mk
YxxtDlw0t/OMscEybkDOwkWReeTOa/GPiO5MldaidXV4bu7CPsnMvZkys0PabO0u
s0JQM3F23f/5yAr2uAc9qqMAq9REaekdHZEy9+tbHJ5bdwi8EUXoR6c4fHp9J8VS
3WVZ5r2OLlKOn3iNGCvRY0kZqM/u6dLELsoIBwmdgtLiPfgX0p+ImpR+VcmOF9Bp
rGJBy2uS2TF/tNwU1knojal0T4ia6geQBY0Nj2Hlxp5VdTlVd8V+1U8DWRCdRKCr
r9nCW8LuEWrAFqZ3hqY1XPBG0s+x9mN9q7PnMD8H7KV3nKy7eYZFzh4/82N6CrTd
KFc9yhZs1zyN6fH050pSnc/n0EwEJcNzy3vhOhwRGW1PKCko+errr+DqgydXLCFl
SSCFfSQJBie1ahz+JKfX4qADaWdOWZDaMojH/pYFIvWz0EP/epkCggEBAOriIC9C
5BSGT8ON8wn3an3P3HSKH2mZEeLnPZG7M9V/mrStbKq9FAAQNJZl5pOFAgzgVg9k
Fk1klJUKHe3F1mTfMhyecj/GKT/Y1qc0fu/dkNmAdgZJGsyHs23ykI0mEd+g2FP5
LUoqQOFv3eR6WfqHMJ6zy1ubooXQOzfNEM8/Tp5ycIfBv+zL0UGPI5HAMv8WMzd8
LNAibKO7zDUn3LFWc9g9cdgjPcwKUB8ePXYS6+3RNYusArOYjfcV0AUYSBhBrn9a
6BDaU1zDRgQTJ95qRWhRXeszE/zUCH4ypqJsOeudT3UwDBdGQ2KoY5cLJatG68pZ
89DTjQKFXAeZs+UCggEBAM9r8+s7wfTcZvTMe7xyMvsb/zTufYZ4PGcMPYmqhzER
9iEGFBgP3MwUOy4sK0wT5GLMVXn3d6dlpqOTa8wxuOM+CsenyVL/vhJgueQWCtQf
rgJI2N+T7CkHGuwjADi293eQFAIfkOsxFdtD+g0kW5kzkSApgI69sB7iA+/P/kOd
2RyycP/zgoebBU8+ZM1QphCOuZMDAHNscunVeelnuQ7ZplqGMuqtEveOWt8H853c
KHh0R95WtoVKczsiwgRqZvN+mvTv7Co1AxnSs/0xTLmipxuxP/iLeQDFwg/6MSGO
suegQOTj7UZxNxH0OPSaY4KhYPJwiuIkMjMVZ4iq6VMCggEAWzzFBba1A+f8Odj8
zCVIP2CroLU6aHlmAj6SovYVt1vey0oGSPgzOacR1k301961oizOISJeq2djc9U/
aSD9okLqoVk6w7bz/nET9eOw6FgC36shtnrrG/3Gabgb2rpkFH5bor6loMtpwuZl
-----END RSA PRIVATE KEY-----


Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest