Execute command using ssh server 'cmd'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execute command using ssh server 'cmd'
# 1  
Old 08-14-2014
Execute command using ssh server 'cmd'

Hi
The command below does not work as it require to take command in the breakers
But If I do so the variable values get lost

ssh testserver01 'dsmc q b "${ARCHIVE_DIR}*" -sub=yes -querysummary -inactive -fromd="${BACKUP_DATE}"'

Thank you.
# 2  
Old 08-14-2014
I'm not familiar with the dmsc utility, but I assume you want something like:
Code:
ssh testserver01 dsmc q b '${ARCHIVE_DIR}*' -sub=yes -querysummary -inactive -fromd='${BACKUP_DATE}'

assuming that you want $ARCHIVE_DIR and $BACKUP_DATE to be expanded on testserver01 rather than being expanded on the local machine and sending the expanded strings to be processed on testserver01. If you want the variables to be expanded on the local machine, change the single quotes above to double quotes. If you want the variables to be expanded on the local machine, but the expanded results need to be quoted on the remote machine, try:
Code:
ssh testserver01 dsmc q b "\"${ARCHIVE_DIR}*\"" -sub=yes -querysummary -inactive -fromd="\"${BACKUP_DATE}\""

You haven't given us any indication of how these variables would be set in either environment.
# 3  
Old 08-14-2014
Quote:
Originally Posted by Don Cragun
I'm not familiar with the dmsc utility
That is the client program of the TSM (Tivoli Storage Manager), IBMs Enterprise backup suite.

Quote:
Originally Posted by Don Cragun
If you want the variables to be expanded on the local machine, change the single quotes above to double quotes. If you want the variables to be expanded on the local machine, but the expanded results need to be quoted on the remote machine, try:
Code:
ssh testserver01 dsmc q b "\"${ARCHIVE_DIR}*\"" -sub=yes -querysummary -inactive -fromd="\"${BACKUP_DATE}\""

This is perhaps the case. From the commands given to dsmc ("q"="query") this is most probably a (site-wide) test if the backup has been taken.

I hope this helps.

bakunin
# 4  
Old 08-14-2014
Thanks you a lot!!!! Works just fine!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to execute setDomainEnv.sh in wblogic via ssh on remote server in shell script?

How to execute setDomainEnv.sh in wblogic via ssh on remote server in shell script we execute setDomainEnv.sh manually as . ./setDomainEnv.sh from its location ie /opt/SP/users/domian/bin" My approach is not working. Please advise. #!/bin/bash set -x base="/opt/SP/users/d1/bin"... (5 Replies)
Discussion started by: abhaydas
5 Replies

2. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

3. Shell Programming and Scripting

Execute a command after ssh exits

In my .tcshrc I define and run an alias to set my terminal title. The title contains the hostname. I do this because I ssh to other machines a lot and I always need to know which host I am typing in. The alias is defined and run in the .tcshrc like this... alias tt 'echo -n "^0;`hostname -s`^G"'... (5 Replies)
Discussion started by: salvadorjoshua
5 Replies

4. Shell Programming and Scripting

Execute command on remote host via ssh

How should i make the following code working #!/bin/bash INPUTFILE="test.txt" while read STRING; do IP=`host -t A $STRING | awk '{print $NF}'` HOSTNAME=`ssh -oPasswordAuthentication=no -oStrictHostKeyChecking=no $IP "hostname"` echo $HOSTNAME > out.txt done < $INPUTFILE At this moment while... (3 Replies)
Discussion started by: urello
3 Replies

5. Shell Programming and Scripting

execute ssh command via perl

Hi I have a perl command that doesn't seem to be working correctly. It appears to be fine but even when i try and run it manually same thing. Can someone take a look at this and tell me what they think the problem could be? Here is the perl Line: system ("echo 'ssh -t -t $user\@$_ \"cd... (3 Replies)
Discussion started by: vpundit
3 Replies

6. UNIX for Dummies Questions & Answers

ssh command to execute shell script in another server

ssh -q <hostname> /opt/tcs/satish/tst.ksh ssh -q <anotherserver> /opt/tcs/satish/tst.ksh tst.ksh has "nohup <command> & " when i execute below script , its throwing error as nohup can not be found ssh -q <anotherserver> /opt/tcs/satish/tst.ksh > log & can someone let me... (5 Replies)
Discussion started by: only4satish
5 Replies

7. UNIX for Dummies Questions & Answers

Unable to execute the complete cmd - using find command

Hi, I'm unable to execute the below command completely ; it's not allowing me to type the complete command. It is allowing till "xargs" and i cannot even press enter after that. I'm using Solaris. Let me know if anything needs to be added so as to execute the complete command. Appreciate... (12 Replies)
Discussion started by: venkatesht
12 Replies

8. Shell Programming and Scripting

ssh execute command remotely

Hi all, Today I want to write a script to run the commands remotely. If I run the command as follows: ssh <user>@<ip> 'ls; pwd' it works fine. But when I want to use ssh to set view in clearcase, it will lose the response. as follows ssh <user>@<ip> 'cleartool setview <view_name>; pwd'... (1 Reply)
Discussion started by: Damon_Qu
1 Replies

9. Shell Programming and Scripting

SSH execute remote command (with jump)

Hi all, I am facing the following issue: Host A should execute a remote command (say pwd) on host B2. B2 is not directly reacheable but you have to connect from a to B1, then from B1 you can execute the command ssh user@B2 pwd. B1 and B2 are directly connected: A => B1 => B2 | ... (3 Replies)
Discussion started by: Evan
3 Replies

10. Shell Programming and Scripting

ssh to remote host and execute command

Hi, could anyone please tell me how to ssh to remote host foo and execute command on it and print the result on local host? Thanks, Paresh (1 Reply)
Discussion started by: masaniparesh
1 Replies
Login or Register to Ask a Question