forcing modified env vars to be effective


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting forcing modified env vars to be effective
# 1  
Old 06-29-2009
forcing modified env vars to be effective

Hi
I have a /bin/sh script, that when executed changes some env vars (like $path).
How can I source the modified cshrc?

I dont want to logout and login to have the modifed path.

sh doesnot recognize source as I understand it is defined only in bash
rehash also doesnot work..

Any ideas please?
Thanks
# 2  
Old 06-29-2009
Does the dot .] operator not work? /bin/sh is probably Bourne shell.
Code:
. .cshrc

# 3  
Old 06-29-2009
Start the script with:

Code:
. ./script

instead of:

Code:
source ./script

# 4  
Old 06-29-2009
I tried, but it doesnot like the "(" for path.

cshrc is as follows after modifying:
set MY_TOOLBOX=/usr/bin/ttx
set TCL_LIBRARY=${MY_TOOLBOX}/lib
set LD_LIBRARY_PATH=${MY_TOOLBOX}/lib
set path=($path /usr/bin/ttx /usr/bin/ttx/FreeBSD ${GGSN_TOOLBOX}/bin)

I get the following /etc/csh.cshrc: 7: Syntax error: "(" unexpected
# 5  
Old 06-29-2009
You are using cshell? Sorry - most of us here cannot help much.
# 6  
Old 06-29-2009
I am trying to change cshrc because csh is the default shell. However, my script uses /bin/sh

This my script:
Code:
#!/bin/sh
if [ -f /etc/csh.cshrc ]; then
       cat /etc/csh.cshrc > /etc/tmp_cshrc
       echo "set MY_TOOLBOX=/usr/bin/ttx" >> /etc/tmp_cshrc
       echo "set TCL_LIBRARY=\${MY_TOOLBOX}/lib" >> /etc/tmp_cshrc
       echo "set LD_LIBRARY_PATH=\${MY_TOOLBOX}/lib" >> /etc/tmp_cshrc
       echo "set path=(\$path /usr/bin/ttx /usr/bin/ttx/FreeBSD \${MY_TOOLBOX}/bin)" >> /etc/tmp_cshrc
        mv /etc/tmp_cshrc /etc/csh.cshrc
        . /etc/csh.cshrc
fi

# 7  
Old 06-29-2009
Code:
set VARNAME=something

is csh syntax
Code:
VARNAME=something
export VARNAME

is bourne shell.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

List of Shell Env Vars

Hia, echo ${!S*} gives me all those env vars starting with S like SHELL SECONDS SHELLOPTS SHLVL etc. is there any way to deflate the shell variables' range like echo ${!A-E*} OR echo ${!A..S*} to list all env vars starting within range of A till E. Thanks Regards, Nasir (1 Reply)
Discussion started by: busyboy
1 Replies

2. Web Development

Deny from env=env-variable Does not work

(Above from Apache docs). On my system, using: SetEnvIf User-Agent Mozilla IsBad=1 Order allow,deny Allow from all Deny from env=IsBad ...I see that environment variable is set (using phpinfo()) but the page is still served. No errors in the Apache logs. (1 Reply)
Discussion started by: gnurob
1 Replies

3. Shell Programming and Scripting

Set/Export Env Vars from with Shell Script With Input Variable

I have a shell script I want to run that will set environment variables based on the value of an input variable submitted when the shell script is called. For example: $ mgenv.sh prod This would set environment variables for prod $ mgenv.sh test This would set environment variables... (1 Reply)
Discussion started by: brtaylor73
1 Replies

4. Shell Programming and Scripting

How to get a filename modified by attaching modified timestamp

Hi, I want to modify a filename in AIX by attaching the last modified timestamp. I want the timestamp completely in numerical format (eg:200905081210. yr-2009, mnth - 05, date -08, hr - 12, mins - 10). For example if the filename is a.log and it was modified on April 6th 2008 at 21.00. I... (16 Replies)
Discussion started by: Ruks
16 Replies

5. UNIX for Dummies Questions & Answers

Forcing Makefile to Ignore Errors

Is there A way I can Force a makefile to ignore errors? i believe it is using gcc. i have a set of commands in the makefile that i want to run and each time the makefile gets to the point of this commands, it aborts because of the commands. how can i get the makefile to keep running... (3 Replies)
Discussion started by: SkySmart
3 Replies

6. UNIX for Dummies Questions & Answers

how to retrieve original contents of a modified file (modified using vi)

Made changes to a file using vi editor and saved those changes now realised that the changes are not required How can I get the previous version of the file.i.e the one which was there on which I had made changes (3 Replies)
Discussion started by: novice100
3 Replies

7. Shell Programming and Scripting

Env vars in a SED script

Hello, <Preamble> I'm writing an installation script for use with PKGADD. What I want to do is take one of the variables set in the REQUEST script and use that in the install script so I can change applications configuration. My install script is as follows: sed ' /^DIRNAME/ i\... (8 Replies)
Discussion started by: Bags
8 Replies

8. Shell Programming and Scripting

Adding command line env in cron env

Hello friends, i run two scripts manually & they work. i run them in cron & they don work. how to match the two env's 1.command line env 2.cron env i would like cron to use command line env. Thanks & Regards Abhijeet (1 Reply)
Discussion started by: abhijeetkul
1 Replies

9. Solaris

forcing users to su

Is there a way in solaris 9 to prevent a user to login via ssh, telnet, rlogin, and only be able to su as that user, for example have DBA joe blow login as jblow, and then su to oracle BUT not vice versa have DBA joe blow login as oralce (6 Replies)
Discussion started by: csaunders
6 Replies

10. UNIX for Advanced & Expert Users

forcing su on a user

This is for 3 os's, AIX, Solaris, and AIX, didnt want to post three seperate times on the same subject, anyways, I want to force the user MQM to su, i.e. not be able to rlogin/telnet to the box as user MQM, only login as there ID(chris for example) and su to MQM, does anyone know how to do this,... (4 Replies)
Discussion started by: csaunders
4 Replies
Login or Register to Ask a Question