#!/bin/bash # Generate password that has guaranteed 1 lowecase, 1 uppercase, 1 special character, minimum 13 characters function generatePass { choose() { echo ${1:RANDOM%${#1}:1} $RANDOM; } { choose '[email protected]#$&' choose '0123456789' choose 'abcdefghijklmnopqrstuvwxyz' choose 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' for i in $( seq 1 $(( 8 + RANDOM % 8 )) ) do choose '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' done } | sort -R | awk '{printf "%s",$1}' echo "" } generatePass
scrituri-bash
Script bash user input
#!/bin/bash #Require user input (select 1 or 2 on keyboard) echo "Continue ?" select yn in "Yes" "No"; do case $yn in Yes ) echo "The script has continued" echo "some command 1" echo "some command 2" break;; No ) exit;; esac done
Script bash pentru monitorizare spatiu pe disk ( hdd )
#!/bin/bash ROOT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g') DATADISK=$(df /var/www | grep / | awk '{ print $5}' | sed 's/%//g') THRESHOLD=85 #Monitor root partition if [ "$ROOT" -gt "$THRESHOLD" ] ; then mail -E -s 'Disk Space Alert' [email protected] << EOF Your root partition remaining free space is critically low. Used: $ROOT% EOF fi #Monitor mounted disk if [ "$DATADISK" -gt "$THRESHOLD" ] ; then mail -E -s 'Disk Space Alert' [email protected] << EOF Your datadisk partition remaining free space is critically low. Used: $DATADISK% EOF fi