Hi everyone,
I have a problem with my shell script. As a quick overview I need to change a template file 6561 times and copy the file into a new catalogue. Thanks to your forum I have managed to write a script to do so:
#!/bin/sh
template=$1
for values in {45,165,285}\ {45,165,285}\ {45,165,285}\ {45,165,285}\ {45,165,285}\ {45,165,285}\ {45,165,285}\ {45,165,285}; do
set $values
A=$1; B=$2; C=$3; D=$4; E=$5; F=$6; G=$7; H=$8
mkdir "A$A-B$B-C$C-D$D-E$E-F$F-G$G-H$H"
cp en ./"A$A-B$B-C$C-D$D-E$E-F$F-G$G-H$H"
cp nf ./"A$A-B$B-C$C-D$D-E$E-F$F-G$G-H$H"
cp define.sh ./"A$A-B$B-C$C-D$D-E$E-F$F-G$G-H$H"
cp cosmoprep.sh ./"A$A-B$B-C$C-D$D-E$E-F$F-G$G-H$H"
sed "s/A\$/$A/;s/B\$/$B/;s/C\$/$C/;s/D\$/$D/;s/E\$/$E/;s/F\$/$F/;s/G\$/$G/;s/H\$/$H/" "template" > ./A$A-B$B-C$C-D$D-E$E-F$F-G$G-H$H/"A$A-B$B-C$C-D$D-E$E-F$F-G$G-H$H"
cd ./A$A-B$B-C$C-D$D-E$E-F$F-G$G-H$H
babel -igzmat "A$A-B$B-C$C-D$D-E$E-F$F-G$G-H$H" -oxyz coord.xyz
source $USELIB/tm510
x2t coord.xyz > coord
sh define.sh
sh cosmoprep.sh
cd /yki/mount/glauber_home/mario8/Desktop/magister/arvutused/6/
done
Finishing this script takes a lot of time and it went well after I checked it after an hour, but at some point it starts to give errors:
def.sh: line 7: /bin/mkdir: Argument list too long
def.sh: line 8: /bin/cp: Argument list too long
def.sh: line 9: /bin/cp: Argument list too long
def.sh: line 10: /bin/cp: Argument list too long
def.sh: line 11: /bin/cp: Argument list too long
def.sh: line 12: ./A285-B285-C285-D285-E285-F285-G285-H285/A285-B285-C285-D285-E285-F285-G285-H285: No such file or directory
def.sh: line 13: cd: ./A285-B285-C285-D285-E285-F285-G285-H285: No such file or directory
def.sh: line 14: /usr/local/bin/babel: Argument list too long
/usr/yki/lib/use/tm510: line 30: /bin/hostname: Argument list too long
/usr/yki/science/turbomole-5.10/Config_turbo_env: line 19: /usr/yki/science/turbomole-5.10/scripts/sysname: Argument list too long
def.sh line 16: /usr/yki/science/turbomole-5.10/scripts/x2t: Argument list too long
def.sh: line 17: /bin/sh: Argument list too long
def.sh: line 18: /bin/sh: Argument list too long
I tried to name a folder with the maximum characters my script had and it worked. So I can't see the problem.
Please, help me.
Mario