H
h00ked
Hi, im just creating script, that will check max filesize before copying.
Testing filesize is exactly 45MB created by:
dd if=/dev/zero of=test.dat bs=47185920 count=1
I created it on linux Debian, like that and its work fine:
Code:
#!/usr/bin/bash
maxsize=50
actsize=$(du -b $1 | cut -f 1)
if [ $actsize -ge $maxsize ]; then
echo "size $actsize is over $maxsize" & exit 2
else
echo "size is $actsize, its OK"
fi
but, on SUN OS doesnt work "du -b"
so, i created somethink like that:
Code:
#!/usr/bin/bash
maxsize=50
actsize=$(du -skh $1 | cut -f 1 | cut -c -4)
if [ $actsize -ge $maxsize ]; then
echo "size $actsize is over $maxsize" & exit 2
else
echo "size is $actsize, its OK"
fi
this is in MB, but.. it does not matter.
Finaly, but... on AIX, again - this system dont know, what is "du -h", "du -b" etc...
I want, if there is solution like that" one script for all system: debian, HP-UX, AIX and SUN OS.
I have backup idea - make system check and use "for system" solution, but its not what i want.
Anyone have some ideas, types or any advice?
Thanks
Continue reading...
Testing filesize is exactly 45MB created by:
dd if=/dev/zero of=test.dat bs=47185920 count=1
I created it on linux Debian, like that and its work fine:
Code:
#!/usr/bin/bash
maxsize=50
actsize=$(du -b $1 | cut -f 1)
if [ $actsize -ge $maxsize ]; then
echo "size $actsize is over $maxsize" & exit 2
else
echo "size is $actsize, its OK"
fi
but, on SUN OS doesnt work "du -b"
so, i created somethink like that:
Code:
#!/usr/bin/bash
maxsize=50
actsize=$(du -skh $1 | cut -f 1 | cut -c -4)
if [ $actsize -ge $maxsize ]; then
echo "size $actsize is over $maxsize" & exit 2
else
echo "size is $actsize, its OK"
fi
this is in MB, but.. it does not matter.
Finaly, but... on AIX, again - this system dont know, what is "du -h", "du -b" etc...
I want, if there is solution like that" one script for all system: debian, HP-UX, AIX and SUN OS.
I have backup idea - make system check and use "for system" solution, but its not what i want.
Anyone have some ideas, types or any advice?
Thanks
Continue reading...