csh failing to call an 2 embedded csh script

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting csh failing to call an 2 embedded csh script
# 1  
Old 06-07-2008
csh failing to call an 2 embedded csh script

I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them)

Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++ programs that are called to perform two different tasks.


# This script is set up to execute in the directory it is called from 
# (ie. The ${PAT_ID} variable is actually = DIAP_xCM_LES_yyMM/wi/ANG) 

if ( ${#argv} == 0 ) then
   echo " Please input gantry angle (format = 000) "
   exit 1

set ANG=${1}

foreach t ( 0 2 4 6 8 ) # so t1 will be set to values of 1,2,3,4,5
  set t1=`echo " scale=0; ( $t + 2 ) / 2" | bc -l`                         
  echo " Mapping dose cube ${t1}... " 

  # Perform the defomation of the dose cubes for each phase using the NCAT deformation vectors and function NCAT_2_MCdose
  /scratch5/jseco/bin/NCAT_2_MCdose /scratch5/jseco/DPM/NCAT/DEFORMATION_VECTORS/ncat_diap_1cm_ph${t1}to1_vec.dat ${ANG}_ph${t1}_w1_H2O.3ddose 256 256 256 1 0
  mv dose_out.3ddose ${ANG}_ph${t1}to1_mapped.3ddose
  rm ${ANG}_ph${t1}_w1_H2O.3ddose

# add the mapped dose cubes together to get a total dose cube for this beam
echo " Adding mapped dose cubes for angle ${ANG}... "
/scratch5/jseco/..../add_dose_joao_weighted ${ANG}_total_mapped.3ddose ${ANG}_ph?to1_mapped.3ddose 0.2 0.2 0.2 0.2 0.2 

# get rid of mapped dose cubes so only dose cube left for this run is the total for this beam and move it into the run directory to sum
#rm ${ANG}_ph*to1_mapped.3ddose

The problem is that only part of the script is being executed. The 'foreach' loop is completed without fail and does exactly what it is supposed too - calls the NCAT_2_MCdose C++ function (which is an image deformation type program). This tells me that the parent script is calling the second script correctly. However, when it attempts to execute the next line of

/scratch5/jseco/...../add_dose_joao_weighted ${ANG}_total_mapped.3ddose ....

it fails. This function has execution permission and the path is correct. Now for the truly strange part. When I run the second script with these two C++ functions in it from the command line it executes perfectly. However, executing it from the parent (first script) only performs the foreach loop and the second program isn't even called (I can't even get any stout or sterr output to be written using the 1> and 2> redirection options.

Is there any suggestions to resolve this? I've spent 2 straight days on this and have finally conceded that I don't know enough and would really appreciate a fresh outlook on this.

Edit: I should add, this second function takes 5 files (with naming convention ${ANG}_ph1to1_mapped.3ddose) and adds them together, each with a weighting of 0.2 with the result being output in the ${ANG}_total_mapped.3ddose. Again, this command works flawlessly when used separately on the command line, or by running this script independently from the parent program.

Last edited by pollsizer; 06-07-2008 at 12:37 AM..
# 2  
Old 06-07-2008

So, it turns out that the executable that was failing is a symbolic link to the real executable located on another disk on our cluster. This symbolic link and the real exe still had full read,write and exec permissions so I'm not sure why this didn't work.

However, end of story - copying the exe to the disk that I was calling it from fixes the problem.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Csh script and tcl

I have csh script and call tck command but it do nothing. can you help me? I only can see it echo #!/bin/csh -f set mypath = `pwd` echo $mypath if ($mypath =~ *PLL*) then echo "source ../PreBoot.qel" else if ($mypath !~ *PLL*) then echo "source ../hdfuse.qel" endif if i remove... (1 Reply)
Discussion started by: sabercats
1 Replies

2. Shell Programming and Scripting

Understanding someone else's csh script...

Hello all. I suspect this will be a simple case for an experienced csh scripter, but google is getting me nowhere on this one. I'm trying to get someone else's set of scripts to work for me, and it's choking when the following script gets called: #! /bin/csh if (x$1 == x) then echo ' you... (1 Reply)
Discussion started by: EinsteinMcfly
1 Replies

3. UNIX for Dummies Questions & Answers

Csh script

Hey all, I've only just started using UNIX coding on my Masters project, so am still learning!! The script I've been writing is literally just for me to get used to writing it and seeing what I can do with some data I've been given. I'm trying to write a script, where the penultimate line... (2 Replies)
Discussion started by: southernlight
2 Replies

4. Shell Programming and Scripting

csh script help

Hey I am brand new to this forum and scripting. I have several documents (1000+) all formated exactly the same. Each document contains 97 lines. I want to pull 3 lines from the documents to populate a file. These 3 lines are line number 9, 24, and 58. Ok my questions: Instead of using... (3 Replies)
Discussion started by: david6789
3 Replies

5. Shell Programming and Scripting

Help with csh script

Ok I asked something similar earlier with no response, so maybe I didn't word it correctly. I'm new at this, so thank you for your help. Here's what I have right now. ---------------------------- > cat MySourceFile #!/bin/csh echo "Please Enter Value For My_Env_Var:" set answer = $< ... (1 Reply)
Discussion started by: MMorrison
1 Replies

6. Shell Programming and Scripting

simple csh script

Hi This little script is giving me error: Syntax error at line xxx : `(' is not expected. Wgat did I miss? RC=0 switch ( $RC ) case 0: echo Done breaksw case -1: echo not done breaksw default: echo "Hello" endsw (2 Replies)
Discussion started by: nimo
2 Replies

7. Shell Programming and Scripting

Simple CSH script

Hi everyone, I have never wrote script in csh before, but I need to add only few lines to an existing one. I tried to use the bash standard syntax, and it did not work. So, I attempted to use csh syntax, and it is not working. Can someone help please: switch ( $Return_Code ) case 0:... (3 Replies)
Discussion started by: nimo
3 Replies

8. Shell Programming and Scripting

Problem with csh script

Hi All, I have the following script. #!/bin/csh # # createDATfile.sh # cd /export/home/fastserv/bin source /export/home/fastserv/bin/dbenv.sh echo `date` >> /export/home/fastserv/bin/log.txt echo "%INF% Starting send of current FASTSERVICE batch" >>... (4 Replies)
Discussion started by: rahulrathod
4 Replies

9. Shell Programming and Scripting

how to call awk in a csh Program

Hi Friends, Could you pleas help me out.. I have an awk program which works fine while running it in the command prompt. The awk program is =============== awk 'BEGIN { format="head -%d M2_Sales_N01.txt |tail -%d >M2_Sales_N01_%02d.txt\n" n=0 m=0 } { if (n==0) { tmp=$1 n=1 }... (5 Replies)
Discussion started by: bikas_jena
5 Replies

10. Shell Programming and Scripting

Calling C from within a csh script

After I compile a C program, when I run it from a C shell script, it does not print out the results. e.g: myCFile.c: main(){printf("Hey");} myCshScript: myCFile This does not output "Hey" to the terminal window. I am not even sure if it is executed or not. What should I do to see the... (2 Replies)
Discussion started by: barisgultekin
2 Replies
Login or Register to Ask a Question

Featured Tech Videos