Sponsored Content
Top Forums Shell Programming and Scripting csh failing to call an 2 embedded csh script Post 302203188 by pollsizer on Friday 6th of June 2008 10:17:17 PM
Old 06-06-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.

Code:
#!/bin/csh

# 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
endif


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
  
end

# 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-06-2008 at 11:37 PM..
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
exit(1) 							   User Commands							   exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 01:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy