Tcsh Shell trouble


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Tcsh Shell trouble
# 1  
Old 03-27-2014
Code Tcsh Shell trouble

Need assistance in getting a solution for a TCSH shell environment variable .
I read on internet that leading zeros as octal numbers and redhat doesnt supports octals but Solaris works on TCSH shell. Is there any way we can fix this . All my script has 08 or 09

Code:
$ @ x = 5 + 08
@: Badly formed number.

Code:
$ @ x = 5 + 8
$

Tcsh version on redhat
Code:
$ /bin/tcsh --version
tcsh 6.17.00 (Astron) 2009-07-10 (x86_64-unknown-linux) options wide,nls,dl,al,kan,sm,rh,color,filec


On Solaris box the tcsh version doesnt through this error
Code:
$ tcsh --version
tcsh 6.12.00 (Astron) 2002-07-23 (sparc-sun-solaris) options 8b,nls,dl,al,kan,rh,color,dspm,filec

# 2  
Old 03-27-2014
Who knows? The C shell is loopy!

All I see is that on Solaris there is no error, but the result is 13, which is still in base 10.

Code:
$ tcsh --version
tcsh 6.17.00 (Astron) 2009-07-10 (i386-sun-solaris) options wide,nls,dl,al,kan,rh,color,filec

% @ x = 5 + 08

% echo $x
13

% printf "%o\n" "$x"
15

You should consider using a better shell.
# 3  
Old 03-28-2014
Scott . I have some old legacy scripts which are running on Solaris so I am migrating it to linux environment . It will be hard to change some 100 scripts to bash . So I need to fix this . I would appreciate if you know which version of TCSH will work on linux
# 4  
Old 03-28-2014
Hi.

I saw that changing:
Code:
@ x = 5 + 08

To:
Code:
@ x = 5 + 8

fixes the error.

As, on Solaris, either returns 13, which is a decimal number not an octal number, that's what I would do!

Can you show me the result of
Code:
@ x = 5 + 08

from your Solaris machine. Perhaps on yours it returns 15 (an octal number)?

On Scientific Linux 6.4, Solaris 11 I have the same version of tcsh (6.17.00 (Astron) 2009-07-10).
# 5  
Old 03-28-2014
Code:
$ @ x = 08
@: Badly formed number.
$ uname -a
Linux ramxtxls1153 2.6.32-358.6.2.el6.x86_64 #1 SMP Tue May 14 15:48:21 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
$ tcsh --version
tcsh 6.17.00 (Astron) 2009-07-10 (x86_64-unknown-linux) options wide,nls,dl,al,kan,sm,rh,color,filec


Code:
$uname -a
SunOS ramxtxus341 5.10 Generic_127111-09 sun4u sparc SUNW,SPARC-Enterprise
$ @ x = 03
$ tcsh --version
tcsh 6.12.00 (Astron) 2002-07-23 (sparc-sun-solaris) options 8b,nls,dl,al,kan,rh,color,dspm,filec

# 6  
Old 03-28-2014
That's interesting. I'm not sure what I did yesterday, but now (on Solaris 11), I do get an error:
Code:
scott@sol11:~$ echo $0
-ksh
scott@sol11:~$ tcsh
> echo $0
tcsh
> @ x = 5 + 08
@: Badly formed number.
> tcsh --version
tcsh 6.17.00 (Astron) 2009-07-10 (i386-sun-solaris) options wide,nls,dl,al,kan,rh,color,filec
>

It's the only version of Solaris I have, but it does have the same version of TCSH (6.17.00) as my RHEL and both give the error. So perhaps it's a "problem" with this version of TSCH (as opposed to 6.12.00 you have on Solaris), or a problem with TCSH on this version (11) of Solaris.

edit: Ah, it seems yesterday, I may have been using CSH, not TCSH. CSH doesn't give the error on Solaris 11, but it still doesn't return an Octal number

Last edited by Scott; 03-28-2014 at 12:08 PM.. Reason: Edited
This User Gave Thanks to Scott For This Post:
# 7  
Old 03-30-2014
The problem is that the leading zero causes some versions of tcsh to interpret "08" as octal eight - which is indeed an invalid octal number.

Download and install tcsh-6.18.01. That version has the behavior you want. You may have to build it from source.
This User Gave Thanks to fpmurphy 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

Trouble understanding shell scripting (mostly wsname)

Am still learning Scripting and I come across a build command that I don't really understand if /local/bin/wsname 2>/dev/null; then base="`/local/bin/wsname`" export base fi if ; then /local/bin/wsname exit 1 fi WSNAME="$base"/ can some one in light me to what... (1 Reply)
Discussion started by: Wpgn
1 Replies

2. Shell Programming and Scripting

Specifying a tcsh shell using winbind

The campus system that I use has switched to using winbind. In the old days, I was able to specify tcsh as my shell with the usual entry in /etc/passwd. But I'm told winbind doesn't have user specific entries, and now my ssh login defaults to a bash shell. Can anybody advise how I can... (2 Replies)
Discussion started by: LeoKSimon
2 Replies

3. Shell Programming and Scripting

tcsh env setting using shell script

Hi All, I have made a file file usercreate.sh & it has to run in tcsh env & needs some path to be set. my script is as below. ########################## #!/bin/csh setenv PATH "/usr/lib/java/class" setenv LD_LIBRARAY_PATH ########################### but when i am ruuning my script... (1 Reply)
Discussion started by: ajaincv
1 Replies

4. Shell Programming and Scripting

[Basic Query]bsh script in tcsh shell

I am a beginner (Just 2 days old:o ), i will really appreciate if you can solve my silly queries as below: Lets say i write a script like this #!/bin/bsh clear #to read name from keyboard echo "your name please.." read fname echo "you just entered $fname" exit 0 My environment is... (2 Replies)
Discussion started by: animesharma
2 Replies

5. Homework & Coursework Questions

Trouble with Advanced Shell Programming

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am working on a hands on project. We are creating a script for a corporate phone list. The project I am... (2 Replies)
Discussion started by: SarahBelle7858
2 Replies

6. UNIX for Dummies Questions & Answers

shell (tcsh) prompt gets reset on every cd

Hi, I type in my shell: set prompt="(%M) %c%b%# " to get something like: a/b/c> this works, but only partially. every time I move to to a different directory (i.e. 'cd <some dir>'), the prompt is reset. Meaning, when I 'echo $prompt' after setting the prompt I get the correct prompt,... (8 Replies)
Discussion started by: yuvalbn
8 Replies

7. HP-UX

How to find tcsh shell version info in HP-UX?

Hi, I need to find tcsh shell version info on several boxes. I made a script and running on boxes through SSH. This is what i am doing : echo /bin/tcsh -c 'echo $version' | ssh "box name" but i dont see anything. if i run /bin/tcsh -c 'echo $version' on ocal machine i see the... (2 Replies)
Discussion started by: kailash19
2 Replies

8. UNIX for Dummies Questions & Answers

About tcsh shell

Hello, Why tcsh shell is not recommended ? then which one is better ? Also can you please let me know how to change own shell and config file? (3 Replies)
Discussion started by: darshakraut
3 Replies

9. Shell Programming and Scripting

how to rename all files that have a certain text in the filename using tcsh shell

Hello~ I'm on AIX version 5 and I believe I have the tcsh shell environment to play in. Can you guys help me with a solution to rename all files that have "eclp" in the filename to "ecl" ? I basically want to rename the files and strip the "p" out. i.e. original filenames: ... (3 Replies)
Discussion started by: in2vtec
3 Replies

10. Shell Programming and Scripting

Having trouble writing a basic shell program

Hello. I'm trying to write a shell script that will take files that have .tar, .tar.gz, .tar.Z, .gz, .Z and .zip file extensions and uncompress and unarchive them. The script should be able to take multiple arguments. So far I can write a script using the case command that will do this but it will... (3 Replies)
Discussion started by: SeanWuzHere
3 Replies
Login or Register to Ask a Question