problem with Variable inside SSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem with Variable inside SSH
# 1  
Old 08-21-2008
Power problem with Variable inside SSH

Hi Friends,

i have small issue,...

here is my problem............Smilie

i am using two unix box A and B ..using my script i am able to connect from A to B without password(using ssh option like below).

A:-> ssh user@B-2.10.32.23

but i declared one variable in A which is something like below..

filename=`find value -l *.csv`

but i could not use the variable inside unix box B.

mean after connecting to B server when i tried using variable filename

it s not giving the value.

i tried using -X option with ssh ..(ssh -X user@B-Host)..

not luckSmilie

anyone can help me please...?

Thanks advance
Sha
# 2  
Old 08-21-2008
Hi! I do not understand your situation well, can you please elaborate on what are you trying to achieve? If possible, can you post your entire command or script that your having problem with? And what does this
Code:
filename=`find value -l *.csv`

do? By looking at it, it looks like it's not a valid "find" command. I maybe wrong though.
# 3  
Old 08-21-2008
Code:
ssh user@B-2.10.32.23 "filename='$filename' sh -i"

If your remote shell of preference is not sh, substitute the one you want. You may need to add or change the options, too.

Last edited by era; 08-21-2008 at 12:32 AM.. Reason: Add paranoid quoting
# 4  
Old 08-21-2008
i don't think you can take a variable from box A to box B by ssh..
try exporting it to box B from box A
# 5  
Old 08-21-2008
Lightbulb

Thanks a lot for all your replay..

yes now i got ...using export option..

Thanks once again..Smilie
Smilie

Sha
# 6  
Old 08-21-2008
i told you.. because i faced the same in my early days with ssh... :-)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem using variable inside awk

HI, This is the code I am using: awk -v aaa="connect" 'BEGIN {IGNORECASE} /aaa/,/!/ {print NR}' bb This does not throw any error but it does not work. Pls help Thanks. (4 Replies)
Discussion started by: sudvishw
4 Replies

2. Shell Programming and Scripting

Not able to store command inside a shell variable, and run the variable

Hi, I am trying to do the following thing var='date' $var Above command substitutes date for and in turn runs the date command and i am getting the todays date value. I am trying to do the same thing as following, but facing some problems, unique_host_pro="sed -e ' /#/d'... (3 Replies)
Discussion started by: gvinayagam
3 Replies

3. Shell Programming and Scripting

problem in assigning substr to a variable inside awk

Hi All, I have a fixed-width datafile from which i need to extract value/string starting from some position to the specified length in each of the lines. awk '{print substr($0,x,y)}' datafile --- is working fine but awk 'BEGIN{a=0}{a=substr($0,x,y);print $a}' datafile ---is giving... (3 Replies)
Discussion started by: loggedin.ksh
3 Replies

4. Shell Programming and Scripting

Problem using ssh inside script

Hi, When runnin the following script it complte successfully with out any problem #!/bin/sh SERV="crm1" for s in $SERV do export WebLogicSessions=`ssh psoft@$s "cd /software/psoft/scripts ; ./getweblogicsessions.sh crm1 8001 PIA | awk '{print $1}' ` echo "Checking number of... (0 Replies)
Discussion started by: yoavbe
0 Replies

5. Shell Programming and Scripting

variable inside variable inside loop headache

Hi Gurus I have a file called /tmp/CMDB which looks like this serial: 0623AN1208 hostname: server1 model: x4100 assetID: 1234 I am writing a for loop that will go through this file line by line creating a variable of itself. Using the first iteration of the loop (i.e. the first line) as... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

6. Shell Programming and Scripting

Problem storing SSH result in a variable

i have this SSH command which runs perfectly on command prompt in sunOS ssh -o Port=${portno} ${uname}@${server} find ${dir_path} -name '***' output : /usr/local/home/*** My problem is when i run same command in my script #!/usr/bin/ksh res=`ssh -o Port=${portno} ${uname}@${server}... (1 Reply)
Discussion started by: prash184u
1 Replies

7. UNIX for Dummies Questions & Answers

passing a variable inside a variable to a function

I would like to know how to pass a variable inside a variable to a function. sample code below -------------- for x in 1 9 do check_null $C$x ##call function to check if the value is null if then echo "line number:$var_cnt,... (2 Replies)
Discussion started by: KingVikram
2 Replies

8. Shell Programming and Scripting

Problem in executing a comand liying inside a variable

Hi everyone! I need some help with my shell script :( I am sending a shell command from a html text input to a cgi. Then, I store it into a variable. For example var="ps -axu" echo `$var` This functions properly. But consider the following... var="ps -axu | grep root" Now, I want... (2 Replies)
Discussion started by: Nene
2 Replies

9. Shell Programming and Scripting

looping a array inside inside ssh is not working, pls help

set -A arr a1 a2 a3 a4 # START ssh -xq $Server1 -l $Username /usr/bin/ksh <<-EOS integer j=0 for loop in ${arr} do printf "array - ${arr}\n" (( j = j + 1 )) j=`expr j+1` done EOS # END ========= this is not giving me correct output. I... (5 Replies)
Discussion started by: reldb
5 Replies

10. Shell Programming and Scripting

ksh: A part of variable A's name is inside of variable B, how to update A?

This is what I tried: vara=${varb}_count (( vara += 1 )) Thanks for help (4 Replies)
Discussion started by: pa3be
4 Replies
Login or Register to Ask a Question