Passing the variable value to remote server.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing the variable value to remote server.
# 1  
Old 10-09-2009
Question Passing the variable value to remote server.

Dear All,

Can anybody explain me how to pass the variable value to command argument which will execute in remote machine.

example..

test="test-123.dbf"

how can i pass this value to command ls -l for remote machine?

I tried to do like this way

ssh root@remote 'ls -l /home/test/${test}'

It is not taking the variable value it is giving the output of ls -l of the folder mentioned which contains the other files too.

pl help me how can i achieve this.

thanks in advance..

Madhu
# 2  
Old 10-09-2009
try changing single qoute to double qoute
Code:
ssh root@remote "ls -l /home/test/${test}"

# 3  
Old 10-09-2009
Cool ... Its worked


Thank u..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete line from remote file over ssh passing variable

I have a variable called $a1 which maps to something like "http://servername proxy1 count http" and a lots of entries in a file on remote server. If I have the following in my .sh script: sed -i "\%$a1%d" mylog.txtthe line is deleted from mylog.txt. Great. I'm trying now to remvoe this from a... (3 Replies)
Discussion started by: say170
3 Replies

2. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

3. Shell Programming and Scripting

Sudo connect to a remote server and execute scripts in remote server

Hello Every one!! I am trying to write a shell script which will connect to a remote server and execute scripts which are at a certain path in the remote server. Before this I am using a sudo command to change the user. The place where I am stuck is, I am able to connect to the... (6 Replies)
Discussion started by: masubram
6 Replies

4. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

5. 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

6. Shell Programming and Scripting

Connect (SSH) to Windows server via Linux server through a script and passing command.. but failing

I am trying to connect to Windows server via Linux server through a script and run two commands " cd and ls " But its giving me error saying " could not start the program" followed by the command name i specify e g : "cd" i am trying in this manner " ssh username@servername "cd... (5 Replies)
Discussion started by: sunil seelam
5 Replies

7. UNIX for Dummies Questions & Answers

Passing of variable values to remote server

Hi, My script will take 3 i/p's from user. Now i need to pass these 3 values to remote server. Please find my code. while do echo " To which server you want to connect ? " echo " 1. server1 \n" echo " 2. server2 \n" read opt_server if then echo "enter the... (2 Replies)
Discussion started by: sree143reddy
2 Replies

8. Shell Programming and Scripting

Creating a variable in remote server

Can anyone help how to create a variable in remote server using shell script. i am connecting to remote server through ssh and creating a variable and assigning the value, but nothing is displayed when i run the script Here is my script ssh hostname <<EOF a=10 echo $a EOF (1 Reply)
Discussion started by: Rahul12341984
1 Replies

9. Shell Programming and Scripting

Passing Values to remote server

I'm trying to pass there values from the present server to the remote server. here is the below code. function abc() { export a=$1 export b=$2 export c="$3" export d="$4" #servers Servers=$(echo server40{1..3}p.s.com) for host in ${Servers}; do #server login ssh $host... (4 Replies)
Discussion started by: Amutha
4 Replies

10. Programming

SFTP from one remote server to another remote server from desktop

Hi, I have 1. lappy 2. server A 3. server B Now, what i need is to run a command from lappy that will sftp a file from server A to server B. Please guide me to achieve this. -akash (1 Reply)
Discussion started by: akash.mahakode
1 Replies
Login or Register to Ask a Question