How to pass CSH variables up to the parent?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to pass CSH variables up to the parent?
# 1  
Old 11-30-2006
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 ACCOUNTS "' >> mipss156t2cmd1.bat
!cat mipss156t2b.ps >> mipss156t2cmd1.bat
!printf '"\n' >> mipss156t2cmd1.bat
!chmod 770 mipss156t2cmd1.bat
!printf 'export ACCOUNTS\n' >> mipss156t2cmd1.bat
;run the BAT file to create the environment variable
!source ./mipss156t2cmd1.bat
!rm -f mipss156t2cmd1.bat mipss156t2tmp1.txt

What I am trying to do here is create a C shell (doesn't have to be C shell) script to create an environment variable called $ACCOUNTS. I then want this value to be available to the QUIZ module (the parent).

The above, even with the !source line, does not work and when I manually echo the $ACCOUNTS variable, it's actually empty! It should not be empty as the mipss156t2b.ps file (a text file) has the value I want to place into ACCOUNTS variable. But, for some reason the variable is "lost" when the above script returns back to the parent (ie. QUIZ program).

I read somewhere that it's not possible to create child variables and have them available to the parent shell. Is this true?

Thank you in advance
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to pass variables into anothother variables?

Below are three variables, which I want to pass into variable RESULT1 username1=userid poihostname1=dellsys.com port1=8080 How can I pass these variables into below code... RESULT1=$((ssh -n username1@poihostname1 time /usr/sfw/bin/wget --user=sam --password=123 -O /dev/null -q... (4 Replies)
Discussion started by: manohar2013
4 Replies

2. Shell Programming and Scripting

pass parameters from perl to csh scripts

I use csh a lot but I don't really write csh scripts. Now I have a need to implement a security check (written in perl; verify an user input security code) into a csh script. Here is the senario: #csh 1. call the perl script 2. if the perl script returns 'true', pass on; if the perl... (1 Reply)
Discussion started by: Julian16
1 Replies

3. Programming

Pass parameter from a child make to a parent

Hello, I have the following problem: I have makefileproj and makefilemod in a build process for a complex project - from makefileproj I call the makefilemod. In makefilemod I generate a list containing objects eg,: "../../../25_Build/Results/Objects/FBL/Fls.o... (4 Replies)
Discussion started by: marina_lmv
4 Replies

4. Shell Programming and Scripting

Exporting variables from subshell to parent shell

Hi, I was trying to do something where I would be able to export one local variable in a telnet subshell to its parent shell. I found something like this over here, but couldnt exactly understand it :(. I am referring to this part actually: #! /usr/bin/ksh exec 4>&1 tail -5 >&4 |& exec... (4 Replies)
Discussion started by: King Nothing
4 Replies

5. Shell Programming and Scripting

How to pass enviroment variable from csh to Informix sql script

Hello, I have a csh script that creates an environment variable. I want to pass the environment variable(CURR_TABLE_DATE) to an Informix sql script. Here is the csh: #!/bin/csh -f setenv INFORMIXSERVER market3_tcp setenv CURR_TABLE_DATE 20090714 set DATABASE = gm_cdr set SQL_DIR =... (0 Replies)
Discussion started by: jwoj
0 Replies

6. Shell Programming and Scripting

[csh] How to capture output from a command and pass it on to a variable?

Hi there! I'm trying to write a script that will capture output from a command and assign it to a variable. Let's say, for example, I'd like to catch from inside the script whatever the following command outputs: ls *.aaa and put it into a variable "listoffiles". What I tried was: set... (3 Replies)
Discussion started by: machinogodzilla
3 Replies

7. Shell Programming and Scripting

how can i pass parameter with spaces to csh script

Hello all i need to pass to my shell script parameter that looks like "2 3 3" inside the script i need to use this string that looks like this "2 3 3" but when i try to print the script im getting syntax error , this is my script : set s = $1 echo $s (1 Reply)
Discussion started by: umen
1 Replies

8. Shell Programming and Scripting

How to change parent shell's variables?

I have a question about how to change variables in parent shell. My script, test.sh, is below: #!/bin/sh # test.sh PATH=. The commands I ran for test: $ echo $PATH .:/usr/bin:/usr/sbin:/usr/local/sbin: $ sh test.sh $ echo $PATH .:/usr/bin:/usr/sbin:/usr/local/sbin: ... (1 Reply)
Discussion started by: pankai
1 Replies

9. Shell Programming and Scripting

Pass csh variable to Perl

Hi All, I am trying to put the csh variable into a perl. In the below case, i am trying to put the csh variable "var" into my perl code. I tried to use '"$var"' but i don;t think it works. Can anybody help me pls? #!/bin/csh set var = `echo "xxx"` perl myperlcode.pl file ... (9 Replies)
Discussion started by: Raynon
9 Replies

10. UNIX for Dummies Questions & Answers

Passing environment variables to parent shells

Hi, I am using bash and need to run a set of tcsh scripts that set environment variables. Is there a way to do this? Any help greatly appreciated. (3 Replies)
Discussion started by: konndanley
3 Replies
Login or Register to Ask a Question
doconfig(3NSL)					       Networking Services Library Functions					    doconfig(3NSL)

NAME
doconfig - execute a configuration script SYNOPSIS
cc [ flag ... ] file ... -lnsl [ library ... ] # include <sac.h> int doconfig(int fildes, char *script, long rflag); DESCRIPTION
doconfig() is a Service Access Facility library function that interprets the configuration scripts contained in the files </etc/saf/pmtag/_config>, </etc/saf/_sysconfig>, and </etc/saf/pmtag/svctag>, where pmtag specifies the tag associated with the port moni- tor, and svctag specifies the service tag associated with a given service. See pmadm(1M) and sacadm(1M). script is the name of the configuration script; fildes is a file descriptor that designates the stream to which stream manipulation opera- tions are to be applied; rflag is a bitmask that indicates the mode in which script is to be interpreted. If rflag is zero, all commands in the configuration script are eligible to be interpreted. If rflag has the NOASSIGN bit set, the assign command is considered illegal and will generate an error return. If rflag has the NORUN bit set, the run and runwait commands are considered illegal and will generate error returns. The configuration language in which script is written consists of a sequence of commands, each of which is interpreted separately. The fol- lowing reserved keywords are defined: assign, push, pop, runwait, and run. The comment character is #; when a # occurs on a line, every- thing from that point to the end of the line is ignored. Blank lines are not significant. No line in a command script may exceed 1024 char- acters. assign variable=value Used to define environment variables. variable is the name of the environment variable and value is the value to be assigned to it. The value assigned must be a string constant; no form of parameter substitution is available. value may be quoted. The quoting rules are those used by the shell for defining environment variables. assign will fail if space cannot be allocated for the new variable or if any part of the specification is invalid. push module1[, module2, module3, . . .] Used to push STREAMS modules onto the stream designated by fildes. module1 is the name of the first module to be pushed, module2 is the name of the second module to be pushed, etc. The command will fail if any of the named modules cannot be pushed. If a module cannot be pushed, the subsequent modules on the same command line will be ignored and modules that have already been pushed will be popped. pop [module] Used to pop STREAMS modules off the designated stream. If pop is invoked with no arguments, the top module on the stream is popped. If an argument is given, modules will be popped one at a time until the named module is at the top of the stream. If the named module is not on the designated stream, the stream is left as it was and the command fails. If module is the special keyword ALL, then all mod- ules on the stream will be popped. Note that only modules above the topmost driver are affected. runwait command The runwait command runs a command and waits for it to complete. command is the pathname of the command to be run. The command is run with /usr/bin/sh -c prepended to it; shell scripts may thus be executed from configuration scripts. The runwait command will fail if command cannot be found or cannot be executed, or if command exits with a non-zero status. run command The run command is identical to runwait except that it does not wait for command to complete. command is the pathname of the command to be run. run will not fail unless it is unable to create a child process to execute the command. Although they are syntactically indistinguishable, some of the commands available to run and runwait are interpreter built-in commands. Interpreter built-ins are used when it is necessary to alter the state of a process within the context of that process. The doconfig() interpreter built-in commands are similar to the shell special commands and, like these, they do not spawn another process for execution. See sh(1). The built-in commands are: cd ulimit umask RETURN VALUES
doconfig() returns 0 if the script was interpreted successfully. If a command in the script fails, the interpretation of the script ceases at that point and a positive number is returned; this number indicates which line in the script failed. If a system error occurs, a value of -1 is returned. When a script fails, the process whose environment was being established should not be started. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
sh(1), pmadm(1M), sacadm(1M), attributes(5) NOTES
This interface is unsafe in multithreaded applications. Unsafe interfaces should be called only from the main thread. SunOS 5.10 30 Dec 1996 doconfig(3NSL)