Xml shema
validation of xml Schema
Xml shema
#!/bin/bash
 
 
xmllint --noout --schema file.xsd file.xml





Bash Loops

Bash Loops
#Loop Through Files
 
for FILE in *; do
  # do something with $FILE
  echo "File: $FILE"
done
 
#For more control, use /usr/bin/file
 
for FILE in $(find ./ -name *.html -type f); do
  # do something with $FILE
  echo "HTML File: $FILE"
done
 
#Loop Through Lines in a File
 
while read LINE; do
  # do something with $LINE
  echo "Line: $LINE"
done < /etc/hosts
 
#Loop Through Words in a File
 
for WORD in $(cat /etc/hosts); do
  # do something with $WORD
  echo "Word: $WORD"
done
 
#Loop Through Characters in a File
 
while read -n1 CHAR; do
  # do something with $CHAR
  echo "Character: $CHAR"
done < /etc/hosts





Bash Trap Control C
Use the Bash builtin trap command to catch system signals. trap define the callback function
Bash Trap Control C
#!/bin/bash
 
control_c_callback()
{
  echo -en "Exiting \n"
  cleanup
  exit
}
 
# trap keyboard interrupt 
trap control_c_callback  SIGINT
 
# main() loop
while true; do read x; done





tcpdump
tcpdump overview
tcpdump
 
#records with tcpdump only on eth0
 
sudo tcpdump -nvi eth0
 
 
#records with tcpdump only on eth0 and some protocol
 
tcpdump -i eth0 arp
tcpdump -i eth0 udp
tcpdump -i eth0 tcp
 
 
#records dns
tcpdump -i eth0 dest port 53
 
 
#records  only on eth0 and packets that match 'not port 22 and not port 21'
sudo tcpdump -nvi eth0 not port 22 and not port 21
 
 
 
#cyclic records 
#
# => when reaching 1 Mb
# => every day
#
 
sudo tcpdump -nvi eth0 -C 1 -G 86400  -W 40  -w /tmp/test%Y-%m-%d--%H-%M.pcap not port 22 and not port 21