set variables on remote system


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers set variables on remote system
# 1  
Old 11-22-2007
set variables on remote system

Hi,

I try to run a script on remote systems with ssh

it should execute a command, read values from stdout, use it as input for a loop
and works with this variable on remote system

but the variable isn't working, I guess because export, echo , or the loop itself are shell builtins and not a binary/script on the remote system

how can I get something like this to work:

ssh hostname "a=5 ; echo $a"

the variable should be set in a new process environment on the remote system, not on local system

or

ssh hostname "for i in $(command1); do command2 $i; done"

thanks in advance

funksen
# 2  
Old 11-22-2007
I suggest you pipe the commands as stdin.

Also it's worth checking what shell the sshd session will actually be running for you.

Code:
ssh user@host <<EOF
echo \$0
echo \$SHELL
ps -p \$\$
EOF

# 3  
Old 11-23-2007
works great, thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

How to set up remote X Windows on AIX ?

Hi, I want to display a program on my local workstation, that is running on a remote AIX, and I have done the following: install an X server (Xming) on my windows machine enable X11 forwarding in Putty enable X11 forwarding for the SSH daemon restart SSH daemon text X... (9 Replies)
Discussion started by: SteAlma
9 Replies

2. UNIX for Dummies Questions & Answers

Set env variables for user

Hi , I have installed oracle in Solaris machine and unable to set the env variable. I tried to put the env variable in .dtprofile file but didn't help. So everytime I login in need to run the command and export the variable. Kindly suggest where I am doing wrong.Pls excuse as I am not too... (2 Replies)
Discussion started by: Rossdba
2 Replies

3. Shell Programming and Scripting

How to set a variable name from another variables value?

Experts, I want to set value of variables like this in bash shell: i=5 ; L=100 I want variable d5 (that is d(i) ) to be assign the value of $L , d$i=$L ; echo $d5 Not working Thanks., (3 Replies)
Discussion started by: rveri
3 Replies

4. Shell Programming and Scripting

Need to SET Environment variables

Hi Could you please tell me how to set environment variables in Unix ksh. And how can acess those varibles in shell scripts ( Please give the code with an example) For my scenario. We have written number of shell scripts with hard coded username and password. But if we want to... (1 Reply)
Discussion started by: shyamu544
1 Replies

5. Solaris

how to login with ssh to remote system with out applying the remote root/usr password

how to login with ssh to remote system with out applying the remote root/user password with rlogin we can ujse .rhosts file but with ssh howits possible plz guide (2 Replies)
Discussion started by: tv.praveenkumar
2 Replies

6. SCO

Help finding where certain environment variables are set

i have two machines that should be identical but on one system there are some oracle environment (ORACLE_SID, ORACLE_HOME, etc...) variables that are not being set for the users. I am trying to find where those environment variables are being set on the system which is working properly. All... (5 Replies)
Discussion started by: kuliksco
5 Replies

7. AIX

How to set permanent variables

I set my TERM variable to work with SMIT and everything works fine but when I logged out and log in again I have to set the variable again. How can I set a permanent variable into the system so it will be as I wish even if a reboot is needed? I set variables this way: export VAR=value (7 Replies)
Discussion started by: agasamapetilon
7 Replies

8. UNIX for Advanced & Expert Users

by using c++ how to set environment variables in unix

hi, I am writing c++ code in unix operating system.In that i need to set the environment variable in unix. suppose previously i have environment variable like path="something" now i need to change the path value to some othervalue . so that some other program will access that path value... (1 Reply)
Discussion started by: sada@123
1 Replies

9. UNIX for Dummies Questions & Answers

Using Variables to Set Other Variables

I have a script that I'm trying to shorten (below) by removing repetitive code. if ] then commodity_ndm_done=Y fi if ] then customer_ndm_done=Y fi if ] then department_ndm_done=Y fi if ] then division_ndm_done=Y fi (3 Replies)
Discussion started by: superdelic
3 Replies

10. UNIX for Dummies Questions & Answers

how to set up linux environment variables?

Hi I'm using Linux, in the directory /root/my there is a.out. but when I try to run it , the shell indicate "bash:a.out: command not found" but I AM working in this directory. if I use "./a.out" , it works perfectly. can any body tell me how to do a permanent set up so that I can use... (5 Replies)
Discussion started by: dell9
5 Replies
Login or Register to Ask a Question