Home | History | Annotate | Download | only in tools
      1 #!/bin/sh
      2 #
      3 #   Copyright (c) International Business Machines  Corp., 2001
      4 #
      5 #   This program is free software;  you can redistribute it and/or modify
      6 #   it under the terms of the GNU General Public License as published by
      7 #   the Free Software Foundation; either version 2 of the License, or
      8 #   (at your option) any later version.
      9 #
     10 #   This program is distributed in the hope that it will be useful,
     11 #   but WITHOUT ANY WARRANTY;  without even the implied warranty of
     12 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     13 #   the GNU General Public License for more details.
     14 #
     15 #   You should have received a copy of the GNU General Public License
     16 #   along with this program;  if not, write to the Free Software
     17 #   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     18 #
     19 #
     20 #   FILE: generate.sh
     21 #
     22 #   PURPOSE: Creates dat for use in network file transfer tests.
     23 #
     24 #   AUTHOR: Randy Hron (rwhron (at] earthlink.net)
     25 #
     26 ############################################################################
     27 
     28 file=$1
     29 size=$2
     30 
     31 if [ -z "$1" ] || [ -z "$2" ] ; then
     32 	echo "usage: ${0##*/} <file> <size in bytes>"
     33 	exit 1
     34 fi
     35 
     36 [ -e "$file" ] && exit 0
     37 
     38 if ! perl -e "print 'A' x $size" > "$file" 2> /dev/null ; then
     39 	if ! awk 'BEGIN { cnt='$size'; while (cnt--) printf "A" }' > "$file" 2> /dev/null ; then
     40 		( while ((size--)) ; do echo -n A ; done ) > "$file"
     41 	fi
     42 fi
     43 
     44 chmod 666 $file
     45