Setting environment variable on a remote solaris machine using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Setting environment variable on a remote solaris machine using shell script
# 1  
Old 05-30-2008
Setting environment variable on a remote solaris machine using shell script

Hi,

I am trying to set environment variable on a remote machine. I want to do it by running a shell script

Here's what I am doin

rsh <remote-hostname> -l root "cd /opt/newclient; . ./setp.sh"

In setp.sh, I have

#############################
cd ../newlib;
export LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/java/jre/lib/i386/client:`pwd`
cd ../newclient

#############################

Output I am getting is


sh: LD_LIBRARY_PATH=::/usr/lib:/usr/java/jre/lib/i386/client:/opt/newlib: is not an identifier

Script is fine when I ran on a remote machine.

. ./setp.sh

Can someone what's wrong with it?

Thanks,
Sundeep

Last edited by eamani_sun; 05-30-2008 at 06:19 PM..
# 2  
Old 05-30-2008
Yes, I know exactly what's wrong. When you're logged in, you're not using the bourne shell. You're using either bash or ksh. When you run the rsh command, the bourne shell is being used.

Your code needs to look like this:
Code:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib:/usr/java/jre/lib/i386/client:`pwd`
export LD_LIBRARY_PATH

That will, by the way, work equally well in bash, sh, or ksh.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute shell script on remote machine

I want to execute a shell script(set of commands) on remote machine and that script takes input from text file(local machine). Please refer below: ssh user@hostname 'bash -s'< ./test.sh file.txt But i got the error file.txt doesn't exist. Can anyone help me on this. Content of test.sh: ... (2 Replies)
Discussion started by: manishtri88
2 Replies

2. UNIX for Dummies Questions & Answers

Execute shell script in remote machine

Hi All, We have 2 servers A and B. B is having a sctipt called b.sh in path /home/dev/scripts. Now my requirement is i want to execute b.sh from server A. Kindly help me. (3 Replies)
Discussion started by: Girish19
3 Replies

3. OS X (Apple)

Quit a shell script thats running on a remote machine

I'm in a situation where I am executing a shell script(Bash) on another machine remotely using ssh, and for various reasons sometimes need to quit it and restart it. The shell script being run does many different things, so its hard to know what process to kill on the remote machine, and even if I... (2 Replies)
Discussion started by: TheDrizzle
2 Replies

4. UNIX for Dummies Questions & Answers

setting a environment variable on linux

I want to set a enviroment variable VDC_DIR to a particular directory. I am doing it as export VDC_DIR=/abc it gets set but when i logout and do relogin than its not there. one way could be setting it in .profile file. but i have seen it on another box where it is not present in... (2 Replies)
Discussion started by: Jcpratap
2 Replies

5. UNIX for Dummies Questions & Answers

how to use ssh to run shell script on a remote machine?

how to use ssh to run shell script on a remote machine? ssh user@remote sh ./script.unx i ran the above command ./script.unx HAS NOHUP COMMAND IN ITS BODY, I AM GETTING ERROR AS NOHUP NOT FOUND... i tried to run that script from remote server, its working fine do ineed to set... (6 Replies)
Discussion started by: only4satish
6 Replies

6. Shell Programming and Scripting

Dynamically setting of environment variable... Can it be done?

Hi all, I am fairly new to unix scripting and will like to know how to dynamically set the name of an environment variable to be used. We have a .env file where we defined the names and locations of data files, trigger files, directories .... etc Example of variables defined in .env... (4 Replies)
Discussion started by: Morelia
4 Replies

7. Shell Programming and Scripting

executing command in a remote machine through ssh - shell script

Hi All, i have two machines like x and y . my requirement is i should connect to machine Y from x through ssh connection . and do some operation such as copy and move and delete files in Y machine . i tried with this code but it is doing in machine x only . and i need to exit from Y when... (1 Reply)
Discussion started by: rateeshkumar
1 Replies

8. Shell Programming and Scripting

Setting environment variable using shell script

Hi All, I'm trying to write an menu driven program to automate some functions which involve loging to multiple hosts. The hosts can differ for every use, so I thought I would use an config file to get the hostnames. Now I need to set those values in the config file to environment variable to... (6 Replies)
Discussion started by: arun_maffy
6 Replies

9. Programming

Setting Environment variable..!

Hi, I already have one CPP program which invokes the C program.And the C program contains whole function definitions..!This is a working program..I have to enable the logs in both CPP as well as in the C program ..!So I am reading the enviornmental variable log path from the CPP and doing the... (2 Replies)
Discussion started by: Kattoor
2 Replies

10. Programming

Setting Environment Variable date

Hi to all... I'm currently running a C++ program in Unix environment and it is dependent to a Unix environment variable with a date value. ex: echo $DateToday 20060403 I want to change that date in my C++ program, changing the value date to 20061120 and revert back to original... (6 Replies)
Discussion started by: d3ck_tm
6 Replies
Login or Register to Ask a Question