populate variable from remote result


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting populate variable from remote result
# 1  
Old 02-19-2007
populate variable from remote result

Hi there

i am trying to pass the result of a remote command into a variable into my script

ie
Code:
#!/bin/sh

var = `ssh remote_box 'uname'`
echo $var

but all i get back is

Code:
./script.sh[3]: var:  not found


However when i add a -x to put it into diag mode i get the following

Code:
+ ssh remote_server uname
+ var = SunOS
./script[3]: var:  not found
+ echo

so it looks like the variable var is actually being populated but i cant echo it


does anybody know what im doing wrong here?

Cheers
Gary
# 2  
Old 02-19-2007
Remove the spaces before and after equal sign
Code:
var=`ssh remote_box 'uname'`

# 3  
Old 02-19-2007
doh !! thankyou
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Store result variable

Friends have the following problem: cat $PATH_DAT/mr.txt | nawk 'BEGIN { CantPnt=0; NumReg=0; FS="|" } { NumReg++ CantPnt=CantPnt+int($2) } END{ printf... (5 Replies)
Discussion started by: tricampeon81
5 Replies

2. Shell Programming and Scripting

How to store remote variable from remote cat file ??

I am trying to cat on a file located on remote server and assign it to remote variable. I have both local and remote variables. Running below script from local. test.sh J_NAME=XXX2 J_IP=XXX ssh $J_IP "ps auxw |grep java | grep -v grep |grep $J_NAME | awk '{print ... (2 Replies)
Discussion started by: oraclermanpt
2 Replies

3. Shell Programming and Scripting

Result of 'cut' into variable

Hello, I would like to have a result of a cut-command in a variable. The file "t.dat" has the following content: Company 001.239879123.OB1X.672W12.STS UNOLD.001.02 My bash-script: Header="" Header=$(cut -c1-160 t.dat | head -1) echo $Header ... (9 Replies)
Discussion started by: API
9 Replies

4. Shell Programming and Scripting

How to combine two variable result?

Hi, i have two variables i.e lck_ckm_customer=ckm_customer and(present in some script A) table=ckm_customer(present in script B) in script B i am executing this part if ; then --- ---- ---- fi Now, while comparing in my log file i am getting this result if but i... (2 Replies)
Discussion started by: gnnsprapa
2 Replies

5. Shell Programming and Scripting

result in variable

Hi all, I'll try to get a result from a search with "awk" into a variable. It works for those examples: findfirstline=`awk 'BEGIN{ mycount = 1 } { if(mycount == 1 && /^Video/){ row=NR; print row; mycount = 0; }}' ${i}` findlastline=`awk '/^Video/ {row=NR} END{print row}' ${i}` But it... (6 Replies)
Discussion started by: tempestas
6 Replies

6. Shell Programming and Scripting

populate a bash variable from an awk operation

Hi, I'm trying to populate bash script variable, data_size with the size of the largest file in my current directory data_size=$(ls -lS | grep -v "total" | head -1) | awk '{ print $5 }' I've tried adding an echo before the call to awk data_size=$(ls -l | grep -v "total" | head -1) |... (2 Replies)
Discussion started by: mark_s_g
2 Replies

7. Shell Programming and Scripting

PHP populate variable with function

Hi, I've a php scirpt that calls in an external class. The external class, myClass, has several public and private functions. There is one public function which derives a value that I want be able to bring it to the main php scirpt. Here is the code. ....snip.... include... (1 Reply)
Discussion started by: nitin
1 Replies

8. Shell Programming and Scripting

Assign result to variable

Hi friends, firstly, i can run following expression and i took 100 value. sqlplus -s username/password@TTTEST @umt.sql umt.sql exists "select t.deger from parametre t where t.id=30". result of this query =100 i need to assign this value(100) to variable(for example x... (2 Replies)
Discussion started by: temhem
2 Replies

9. Shell Programming and Scripting

running command remotely to populate local variable

If I run this # ssh remote-server 'du -sk /usr/platform/`uname -i`/' 174 /usr/platform/SUNW,Sun-Fire-V245 I get my output just fine, However, if i try to do the same but populate a local variable within my script called for example 'result' #!/bin/ksh result=`ssh remote-server... (3 Replies)
Discussion started by: hcclnoodles
3 Replies

10. UNIX and Linux Applications

How to get a result of a cmd into variable?

Hi , I am trying following . I need to get a result of an autosys cmd into a unix variable. The autosys cmd is autostatus -G jpm_day_today Please help me in storing the value returned by this cmd into a unix variable. Appreciate your time to read this post. (1 Reply)
Discussion started by: manchau
1 Replies
Login or Register to Ask a Question