Having Issues in Csh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Having Issues in Csh
# 1  
Old 10-30-2011
Having Issues in Csh

I am having the worst time trying to figure out this simple little script and I'm about to go nuts.

I have to use csh to create this script for a class and the problem I run into is checking my number range, just validating that the number is between 1 and 9 inclusive. I tried:

Code:
if [1 <= $number && $number <= 9]
   ...
else
   ...
endif

But it gives me a file redirection error message and I understand why, my brain is just quitting on me in trying to figure out how to fix it. Any help would be greatly appreciated! Smilie
# 2  
Old 10-30-2011
Can you post the entire script? Also when you run it, it should post an error message, paste the exact error as well.
# 3  
Old 10-30-2011
I will remember that for next time, I actually just figured it out >.<

Figured out that brackets and parentheses are not interchangeable and that I had my $number on the wrong side of the inequality, hence the redirecting error message.

Thanks though, and I will definitely remember to post the entire thing plus error messages next time Smilie
# 4  
Old 10-31-2011
Quote:
Originally Posted by Vyrlissa
I am having the worst time trying to figure out this simple little script and I'm about to go nuts.

I have to use csh to create this script for a class and the problem I run into is checking my number range, just validating that the number is between 1 and 9 inclusive. I tried:

Code:
if [1 <= $number && $number <= 9]
   ...
else
   ...
endif

But it gives me a file redirection error message and I understand why, my brain is just quitting on me in trying to figure out how to fix it. Any help would be greatly appreciated! Smilie
Code:
if ( $number >= 1 && $number <= 9 ) then

# 5  
Old 10-31-2011
Yep, I know ygemici, that's what I posted above your post that I had figured it out.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

(t)csh command line arguments issues

1. The problem statement, all variables and given/known data: create a shell script, chExt.sh that takes one or more parameters, where the first is a desired extension and the remainder are names of files to be renamed. For each file in the command line, this script should rename the file, as... (6 Replies)
Discussion started by: kcoll025
6 Replies

2. Shell Programming and Scripting

What does this do in CSH?

CSH experts What does the following do in CSH? :(){:|:&};: I was asked the question, but I don't know. I'm not aware of the context. Any ideas? Thanks! (1 Reply)
Discussion started by: wallg
1 Replies

3. Shell Programming and Scripting

.sh to .csh

Hi All, Could any one of you give me a hand to convert the following line of codes from .sh to .csh please ? proc_id=`fuser /tmp/test` if then echo "File is not being used by any thing" fi if then echo "File is being used... please wait" sleep 1 fi Regards. (1 Reply)
Discussion started by: sraj142
1 Replies

4. Shell Programming and Scripting

Using \n in csh

I am trying to use \n for a new line in csh like this echo "some text\n" echo "some more text\n" but am getting some text\n some more text\n (10 Replies)
Discussion started by: kristinu
10 Replies

5. Shell Programming and Scripting

if in csh

I am using this code echo "opt_tpath = $opt_tpath" if ($opt_tpath == 1) echo " -tpath = $Atpath\n" and is giving opt_tpath = 0 Atpath: Undefined variable. Atpath should only be printed in opt_tpath == 1 but it still tries to print. ---------- Post updated at 10:05 AM ----------... (1 Reply)
Discussion started by: kristinu
1 Replies

6. UNIX for Dummies Questions & Answers

csh

what is a .csh extension? there is a command line: mkaphed_ctio.csh Does anyone know what this is? :confused::confused::confused: (1 Reply)
Discussion started by: cosmologist
1 Replies

7. Shell Programming and Scripting

csh in solaris

how can i pre-set then PATH so that i no need setenv everytime i login. i know it can be done with edit .login on normal user but how about root? (1 Reply)
Discussion started by: conandor
1 Replies

8. Shell Programming and Scripting

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++... (1 Reply)
Discussion started by: pollsizer
1 Replies

9. UNIX for Dummies Questions & Answers

Csh Vs Ksh

I created a simple script and attempted to run it. All that the scrip contained was "ls -l". At first I received the message "ksh: run_dir: not found" I then tried typing "csh run_dir" This time the script worked. typing echo $SHELL produced /bin/ksh I would like to understand why this... (4 Replies)
Discussion started by: SUSANR9999
4 Replies

10. UNIX for Dummies Questions & Answers

how to zero a file using csh

Hi I have always used ksh in the past, but now am using csh. To zero a file using ksh, you simply > filename. What is the command to do the same using csh? Thanks in advance. (3 Replies)
Discussion started by: jodie
3 Replies
Login or Register to Ask a Question