Regarding c-shell (csh) scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Regarding c-shell (csh) scripting
# 1  
Old 12-09-2012
Regarding c-shell (csh) scripting

Hi,

I'm reading a csh setup script, and came across these lines:

Code:
################################

if (! $?PROJECT_ROOT) then
    setenv PROJECT_ROOT /proj/proj_123
endif

################################

Does the if endif command means, "if there is no variable named "PROJECT_ROOT", then set it to "/proj/proj_123" ?

What if there already exist a variable named "PROJECT_ROOT" ?
Moderator's Comments:
Mod Comment Please use code tags

Last edited by jim mcnamara; 12-09-2012 at 11:53 PM..
# 2  
Old 12-09-2012
nothing happens.
# 3  
Old 12-09-2012
Is my assumption on the lines are correct? I'm new to scripting fyi :

"Does the if endif command means, "if there is no variable named "PROJECT_ROOT", then set it to "/proj/proj_123" ?"
# 4  
Old 12-09-2012
if - is a logical branch and starts a distinct block of code

any
line in here
gets executed when the if statement is true

endif ends the block of code, it is a marker for the end of the if - block it does not affect logic.

Therefore if the variable is not defined, as the if statement asks, then any line of code up to but not including the endif gets executed.

The endif does nothing as rcdwayx explained.

Last edited by jim mcnamara; 12-09-2012 at 11:58 PM..
This User Gave Thanks to jim mcnamara For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

String operation in csh shell

Hi, to everybody i have a string which Looks like this FT47;3;1;1;;;1;09.02.2017 21:21:19;2;2 and i would like to change to value on one Position only e.g. the values on Position 6 should change to 1 nevertheyless which values was there before AIX 4.3.2.0 and csh i try... (10 Replies)
Discussion started by: Nadielosabra
10 Replies

2. Shell Programming and Scripting

Pass C shell array to another C shell script(csh) and shell(sh)

Dear Friends, Please help me on this my script name is send.csh In this i have written the statement like this set args = ( city state country price ) I want to pass this array to another c shell called receiver.csh. and i want to use it in this c shell or how to pass to... (2 Replies)
Discussion started by: SA_Palani
2 Replies

3. Programming

csh: Parameters in Shell Script Help

I have a program that is designed to take the first parameter (a file extension) and use it to rewrite the file stored in the second paramerter with the new extension. And if the current file does not exist then the program will print an error message "No such file." For example, my program is... (1 Reply)
Discussion started by: Marhsall34
1 Replies

4. UNIX for Dummies Questions & Answers

Problem with simple csh scripting

I found my answer... (2 Replies)
Discussion started by: sjung9442
2 Replies

5. Shell Programming and Scripting

4x4 Array in csh scripting

I am trying to code a 4 by 4 array. However the naming convention is diffrent. Please refer the image below https://lh5.googleusercontent.com/-Dl0vdjfXtU0/Tnh02_ORJpI/AAAAAAAAAKU/4c2zyFP9IB0/array.JPG I want to name them in order : from 0 to 3 --> (0,0) cell to (0,3) from 4 to 7 --> (1,0)... (0 Replies)
Discussion started by: animesharma
0 Replies

6. Shell Programming and Scripting

Filenames in CSH shell

Hi, I am running into a bit of a problem. I am trying to write a script that will run an interactive (fortran) program repeatedly to dump data across 36 data channels... anyway. I have gotten this far... #!/bin/csh set i=0 while ($i<2) fitsfilter $1<<EOF $i 0 9 1 1 g 2 1250 -100... (5 Replies)
Discussion started by: madtowneast
5 Replies

7. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

8. Shell Programming and Scripting

different shell csh bash

I'm always having to work in the cshell, but occasionally want to run a command using bash. is that possible? I know I could write a shell script and call bash at the begining with #!/usr/bin/bash and then my command, is there another way? (1 Reply)
Discussion started by: ajp7701
1 Replies

9. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

10. UNIX for Dummies Questions & Answers

Options for csh shell

Hello, It's possible to change/put some options of the C-shell, like bold-text, date, etc? I can't found a web site that have a explanation. Thanks. (10 Replies)
Discussion started by: luiz_fer10
10 Replies
Login or Register to Ask a Question