The same script with extra variables seems to fail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting The same script with extra variables seems to fail
# 1  
Old 04-01-2010
The same script with extra variables seems to fail

Hey everyone,

I have a problem with a certain shellscript. I have a script like this:

Code:
#!/bin/sh

template=$1
for values in {60,150,240,330}\ {60,150,240,330}\ {60,150,240,330}\ {60,150,240,330}; do
    set $values
    X=$1; Y=$2; Z=$3; M=$4
    mkdir "X$X-Y$Y-Z$Z-M$M"
    cp define.sh ./"X$X-Y$Y-Z$Z-M$M"
    cp cosmoprep.sh ./"X$X-Y$Y-Z$Z-M$M"
    sed "s/X\$/$X/;s/Y\$/$Y/;s/Z\$/$Z/;s/M\$/$M/" "$template" > ./X$X-Y$Y-Z$Z-M$M/"X$X-Y$Y-Z$Z-M$M"
    cd ./X$X-Y$Y-Z$Z-M$M
    babel -igzmat "X$X-Y$Y-Z$Z-M$M" -oxyz coord.xyz
    source $USELIB/tm510
    x2t coord.xyz > coord
    sh define.sh
    sh cosmoprep.sh
    cd ..
done

and it is working fine! But if I extend the variables like this:

Code:
#!/bin/sh

template=$1
for values in {60,150,240,330}\ {60,150,240,330}\ {60,150,240,330}\ {60,150,240,330}\ {60,150,240,330}\ {60,150,240,330}; do
    set $values
    X=$1; Y=$2; Z=$3; M=$4; N=$5; Q=$6
    mkdir "X$X-Y$Y-Z$Z-M$M-N$N-Q$Q"
    cp define.sh ./"X$X-Y$Y-Z$Z-M$M-N$N-Q$Q"
    cp cosmoprep.sh ./"X$X-Y$Y-Z$Z-M$M-N$N-Q$Q"
    sed "s/X\$/$X/;s/Y\$/$Y/;s/Z\$/$Z/;s/M\$/$M/;s/N\$/$N/;s/Q\$/$Q/" "$template" > ./X$X-Y$Y-Z$Z-M$M-N$N-Q$Q/"X$X-Y$Y-Z$Z-M$M-N$N-Q$Q"
    cd ./X$X-Y$Y-Z$Z-M$M-N$N-Q$Q
    babel -igzmat "X$X-Y$Y-Z$Z-M$M-N$N-Q$Q" -oxyz coord.xyz
    source $USELIB/tm510
    x2t coord.xyz > coord
    sh define.sh
    sh cosmoprep.sh
    cd ..
done

Then the script works fine at the first few hours, but fails afterwards, giving an error:

Code:
Config_turbo_env: TURBOMOLE script sysname failed!
defineerija_lahus.sh: line 14: coord: Permission denied
defineerija_lahus.sh: line 15: /bin/sh: Argument list too long
defineerija_lahus.sh: line 16: /bin/sh: Argument list too long
defineerija_lahus.sh: line 7: /bin/mkdir: Argument list too long
defineerija_lahus.sh: line 8: /bin/cp: Argument list too long
defineerija_lahus.sh: line 9: /bin/cp: Argument list too long
defineerija_lahus.sh: line
10: ./X330-Y150-Z240-M150-N330-Q60-A60-B150/X330-Y150-Z240-M150-N330-Q60-A60-B150: No such file or directory
defineerija_lahus.sh: line 11:
cd: ./X330-Y150-Z240-M150-N330-Q60-A60-B150: No such file or directory
defineerija_lahus.sh: line 12: /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
Config_turbo_env: TURBOMOLE script sysname failed!

And it turns out it starts to make new files into other folders. It seems it makes more "cd .." commands then I ask it to.

I would be really thankful if anyone could explain me why the script fails Smilie .

Thanks in advance,

Mario
# 2  
Old 04-01-2010
More safty cd using ?
Code:
now=$PWD
for ...
do 
      cd some
     ...
     cd $now # be sure, return to same dir always
done

tm510 not include cd ?
Put echo before other lines as cd and comment sed line.
# 3  
Old 04-01-2010
Thanks, I am going to try it tomorrow at work.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Fail Parent Script if any of the child fails

I have requirement where I need to fail parent if any one of the child process fails. Here is the code snippet for i in 1 2 3 4 5 6 7 8 9 10 do child_script $i & done wait I need to fail my main script if any one of my child process fails (8 Replies)
Discussion started by: gvkumar25
8 Replies

2. Shell Programming and Scripting

sed commands success / fail from commandline vs ksh script

solaris 5.10 Generic_138888-03 sun4v sparc SUNW,Sun-Fire-T200 I need a sed command that tests true when presented with lines that contain either forward and backslash. input file: c:/myFile.txt c:\yourFile.txt It doesn't appear that sed (in my environment anyway) supports... (4 Replies)
Discussion started by: msutfin
4 Replies

3. Shell Programming and Scripting

Banner causes scp to fail from script but not command line.

Hi, We have an interesting issue which is similar to the one in this thread, but that never provided a full answer. - Ohh apparently I can't post URLs till I have 5 posts, sorry. We have a simple script that copies files from one shelf to the other. Both shelves have an ssh banner defined. ... (3 Replies)
Discussion started by: RECrerar
3 Replies

4. Shell Programming and Scripting

A simple script fail

Hi, I am a programming newbie, I have started learning C++ a couple of months ago. Unfortunately I don't have too much time in my hands to learn it properly. I need to write a simple script for a project I am doing but I am failing quite hard :mad: (the fact that I am learning C++ is completely... (3 Replies)
Discussion started by: Akhlore
3 Replies

5. Shell Programming and Scripting

tr command fail to work in script

Hi, I has the following command in the script. This command works fine if I execute on command prompt. If I run the script, this is not working as expected (deleting CR). tr -d "\015" < ${FilePath}/${FileName} > ${FilePath}/${File_Prefix}.csv I could not figure out whats... (6 Replies)
Discussion started by: kavuri
6 Replies

6. Shell Programming and Scripting

Extra output in the script

Hi , I am trying to execute the following script. #!/bin/sh find . -name "common.log.diff" if ; then cp common.log common.log.diff diff common.log common.log.diff > DIFFERENCE.log cp common.log common.log.diff grep "ERROR" DIFFERENCE.log if ; then echo "1" else echo "0" fi... (5 Replies)
Discussion started by: himvat
5 Replies

7. Shell Programming and Scripting

fail a unix script

i am basically DWH professional. I want to write a script such that whenver the file size is greather than 0 the script fails (6 Replies)
Discussion started by: er_zeeshan05
6 Replies

8. Shell Programming and Scripting

Need some help with this script -- extra eyes

I have two issues with this script. 1. I cannot seem to get my counters to count correctly. 2. My function to eject to CAP1 or CAP2 is hung in a loop and doens't exit back to the previous function. I would like to be able to select which cap to eject to . Each cap holds only 40 tapes, so when one... (15 Replies)
Discussion started by: gzs553
15 Replies

9. Shell Programming and Scripting

Environment variables causing cronjob to fail

I am trying to run a script which makes use of these environment variables, hence i need to export them out. i've posted a similar post in an oracle forum. I've posted the same qn here to get some advise on the scripting aspect. i execute my program in an unix environment by typeing... (2 Replies)
Discussion started by: new2ss
2 Replies

10. UNIX for Advanced & Expert Users

Fail to run init-script from crontab

I have written a "simple" shell-script (BASH) to monitor the logs of our Resin-applicationserver. Whenever Resin runs out of available heap-space, the script then tries to restart the Resin-server. My problem is that my "autopilot"-script fails when it's run from crontab. Here's what the... (5 Replies)
Discussion started by: indo1144
5 Replies
Login or Register to Ask a Question