How to use ifdef for bash variables in csh environment?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use ifdef for bash variables in csh environment?
# 1  
Old 06-19-2012
How to use ifdef for bash variables in csh environment?

Hi Guys,

I have a a bash script and i am exporting a variable in it.
I am calling a csh script from this bash script.

The variable "ABC" will be visible in csh script.

ks.bash
Code:
export ABC = abc
./kp.csh

ab.csh
Code:
echo $ABC  
setenv ABC =cde (i want to assign this value to ABC only if its not defined in bash)

kp.csh
Code:
source ab.csh

I want to change the value of "ABC" in csh script if its not defined in bash script.
# 2  
Old 06-19-2012
change your ab.csh with below and execute your ks.bash
Code:
if (! $?ABC ) setenv ABC cde

# 3  
Old 06-19-2012
The problem is, i have 20 such variables like "ABC". So it will not be a good way to go ahead.
Anything like "ifdef" which can be used instead.
# 4  
Old 06-19-2012
Quote:
Originally Posted by vdhingra123
The problem is, i have 20 such variables like "ABC". So it will not be a good way to go ahead.
Anything like "ifdef" which can be used instead.
what is your full code ? where are they (20 vals) ?
# 5  
Old 06-19-2012
Its a huge script which has these variables, which can be set from the command line to get the desired functionality.
The problem is, my top script is bash. If i define these in csh then If i want to write new values to these variable from my top Bash script i cant do that.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Issue nesting variables in csh.

The variables given are already defined ($file1-$file3, $obsid1-$obsid3, and $n=3). When I go to run the code, the terminal outputs "Missing }." I believe the error is with the nesting of variables. It would save a lot of time getting this while loop working. set i = 1 while (${i} <=... (5 Replies)
Discussion started by: ojdefdidit
5 Replies

2. Shell Programming and Scripting

Sourcing .cshrc (C shell) environment variables to bash

I have tried with the following: csh -c 'source ~/.cshrc; exec bash' # works perfectly (cat ~/.cshrc; echo exec bash) | csh # not working And, using sed, I successfully retrieved the environment variables from ~/.cshrc sed -rn 's/setenv\s+(\S+)\s+(.*)$/export \1=\2/p' ~/.cshrc but now... (6 Replies)
Discussion started by: royalibrahim
6 Replies

3. Shell Programming and Scripting

How to access the bash variables in csh

Hi, I am having a primary script which is Bash based. I am calling a csh script from it. Now, their are some variables defined in my bash script which i need in csh. I am unable to do so. Is it possible ? (2 Replies)
Discussion started by: vdhingra123
2 Replies

4. Shell Programming and Scripting

How to run csh environment parameters from k-shell script?

Hi Guys, I need to run an alias from a k-shell script ,for example 10204, which points to : source $ORACLE_BASE/scripts/cshrc/10204/.cshrc Meaning , I need to run in my k-shell script with the env settings parameters of the alias. How to do it in k-shell? Thanks in advance, Nir (2 Replies)
Discussion started by: nir_s
2 Replies

5. Shell Programming and Scripting

Perl Csh - setenv ENV change environment variable

I have 3 programs, 1 in perl, 2 in csh: call them perl1, csh1 and run.ol I need perl1 to set csh1 variable NOLOG_qsub = "" I need perl1 to run, run.ol run.ol takes the executable and input and outputs to output run.ol#!/bin/csh -f # run.ol executable input output perl1 should... (1 Reply)
Discussion started by: austinj
1 Replies

6. Shell Programming and Scripting

Max number of environment variables in Csh

Anyone knows what is the max limit of number of environment variables in Csh? I have a script that when run causes the shell to stop responding to any command like: ls /bin/ls: Argument list too long. And I guess the reason is I passed the max limit for number of environment variables... (1 Reply)
Discussion started by: mohy
1 Replies

7. Shell Programming and Scripting

Unable to change environment variables in bash script

Hello! For the moment some settings in my .bashrc contain the password of my company's firewall, which is not a good idea. I would like to use the string "PASSWORD" set in .bashrc and a script that changes all appearances of "PASSWORD" in the environment variables by the actual password (which... (4 Replies)
Discussion started by: markolopa
4 Replies

8. Homework & Coursework Questions

BASH Environment Variables as arguments?

1. The problem statement, all variables and given/known data: Write a shell program called myenv which takes one argument. The argument should be the name of an environment variable, such as PATH HOME etc. myenv should print out the value of the variable given as the argument. If no argument is... (1 Reply)
Discussion started by: Helix
1 Replies

9. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

10. Shell Programming and Scripting

How to pass CSH variables up to the parent?

Hi .. I have a dynamic script called from a programming language called Powerhouse (4GL). The module, called QUIZ, allows the user to call shell commands from within it... i.e. !rm -f mipss156t2cmd1.bat mipss156t2tmp1.txt !printf '#!/bin/csh\n' > mipss156t2cmd1.bat !printf 'setenv... (0 Replies)
Discussion started by: ElCaito
0 Replies
Login or Register to Ask a Question