Csh variable calling problem | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Csh variable calling problem

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-06-2013
sabrepride sabrepride is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 6 March 2013, 6:10 PM EST
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Csh variable calling problem

First post on here. So I use csh shells for my research (physics... not a CS person). I am trying to rerun the same scripts, but there are ~10 files that have similar variables that I have to change for each different configuration, so I would like one central file for the variables I change that get used in the various csh files.

Basically what I have been trying to do by scouring the internet but have had no success is to have a document with values:

Code:
l2064f211b600m011m055m645
l2064f211b600m011m055m645b
l2064f211b600m011m055m645c
l2064f211b600m011m055m645d
('0.645 0.645 0.645' '0.011 0.011 0.011' '0.011 0.011 0.055' '0.011 0.055 0.055'  '0.055 0.055 0.055')
(645 011 011m 055m 055)
1.2
1.2
1.2
64
32
36

and then be able to call them in different csh files as if I had just done

Code:
set mass = ('0.645 0.645 0.645' '0.011 0.011 0.011' '0.011 0.011 0.055' '0.011 0.055 0.055'  '0.055 0.055 0.055'), but instead from the file (call it specs)

, where I could then reference it later as $mass[$1] for 0.645 0.645 0.645.

I have tried to do
Code:
mass=$(awk 'NR==$1' specs)

, but I keep getting 'invalid variable' when I run the csh script.
Sponsored Links
    #2  
Old 03-06-2013
Corona688 Corona688 is online now Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 24 April 2014, 3:10 PM EDT
Location: Saskatchewan
Posts: 18,539
Thanks: 682
Thanked 3,036 Times in 2,856 Posts
Do you absolutely have to use csh? It makes everything harder.
Sponsored Links
    #3  
Old 03-06-2013
sabrepride sabrepride is offline
Registered User
 
Join Date: Mar 2013
Last Activity: 6 March 2013, 6:10 PM EST
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
I would like to stay with it because I have large programs written. I knew someone would bring this up, next project I start ill change to something more modern.
    #4  
Old 03-06-2013
Corona688 Corona688 is online now Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 24 April 2014, 3:10 PM EDT
Location: Saskatchewan
Posts: 18,539
Thanks: 682
Thanked 3,036 Times in 2,856 Posts
You are already trying to use bourne shell! $() is bourne syntax. You only get to use `` in csh.

csh can't do the kind of doublethink where you put a csh statement in a variable then execute it, either. sh can, but you have to force it, since it's very seldom a good idea to do so.

This will get them in an array where each number is its own index:


Code:
set VAR = ( `tr -d ",()'" < infile` )

...which you can then process with a loop to get the numbers three to an index like you want.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Calling awk fom csh kristinu Shell Programming and Scripting 1 10-18-2010 07:08 PM
Calling awk from csh kristinu Shell Programming and Scripting 2 06-29-2010 05:09 PM
Reading a variable in csh pt14 Shell Programming and Scripting 4 06-28-2010 09:03 AM
calling csh script from ksh shell JamesByars Shell Programming and Scripting 3 12-18-2008 12:52 PM
Calling C from within a csh script barisgultekin Shell Programming and Scripting 2 05-24-2002 09:21 PM



All times are GMT -4. The time now is 03:14 PM.