SSH and Backticks [solved]


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SSH and Backticks [solved]
# 1  
Old 05-13-2012
SSH and Backticks [solved]

I have been testing a new script and cannot figure out why my `cat spath` will not execute on the remote machine?

PHP Code:
sudo ssh -p 22344 -"PasswordAuthentication no" -"HostbasedAuthentication yes" -l testuser 192.168.1.6 "find `cat spath` -depth"
 
catspathNo such file or directory 
but this will command does work when I use it with the ticks:

PHP Code:
sudo ssh -p 22344 -"PasswordAuthentication no" -"HostbasedAuthentication yes" -l saint 192.168.1.6 "cat spath" 
/var/www/ /etc /var/spool /home/testuser 
What is the trick?

---------- Post updated at 01:19 AM ---------- Previous update was at 12:30 AM ----------

I figured it out. Using the double quotes and backticks caused the local shell to interpret the command

PHP Code:
sudo ssh -p 22344 -"PasswordAuthentication no" -"HostbasedAuthentication yes" -l testuser 192.168.1.6 "find `cat spath` -depth"
 
catspathNo such file or directory 
using a single quote and using () seemed to have fixed the issue:

PHP Code:
sudo ssh -p 22344 -"PasswordAuthentication no" -"HostbasedAuthentication yes" -l testuser 192.168.1.6 '(find `cat spath` -depth)'
/home/testuser
/home/testuser/caca 
ssh runs remote commands as what remote user??

good day gents
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Ssh to windows from linx

Hi, I was trying to ssh to windows server from linux box(red hat). I am a bit confused about where to generate the keys. Should I generate the keys in linux and place it in windows or other way around. I have installed openssh package in cygwin on the windows box. can someone please tell me... (0 Replies)
Discussion started by: ahmedwaseem2000
0 Replies

2. UNIX for Advanced & Expert Users

[Solved] SSH key authentication problem

Hi All, this is the very first time i am going to use SSH authentication. first i login to server@ and under this ..ssh directory of servera i used this following command: ssh-keygen -t rsa -b 1024 and i had 2 files(bravo_dbtest and bravo_dbtest.pub) created respectively, further i copied the... (13 Replies)
Discussion started by: lovelysethii
13 Replies

3. Ubuntu

[Solved] Ssh and scp between two vmware Ubuntu

Hello, Please, I would like to connect a VM to another: I typed as follows: ssh root@192.168.1.4 root@192.168.1.4 's password: Permission denied, please try again. root@192.168.1.4 's password: Permission denied, please try again. root@192.168.1.4 's password: Permission denied... (6 Replies)
Discussion started by: chercheur111
6 Replies

4. Shell Programming and Scripting

[Solved] Not able to read the next line from a file after doing ssh

Hi, I am trying to write a code, where it reads the jobnames from a file and checks for the logs in the server. If the log is not found in the first server, then it will ssh to the 2nd server and get the details from there. I will need to save the date in a variable. But the problem is that,... (0 Replies)
Discussion started by: ajayakunuri
0 Replies

5. Shell Programming and Scripting

[SOLVED] put dd | ssh command in backgound

Greetings, I have an issue that has baffled me. I have done many searches, read the man documentation, and I have yet to find a solution. I am trying to run the following command within a script to copy a file across servers: $(dd if="$FDIR" bs=1024 2> /dev/null | ssh "$(whoami)@$SERVER"... (5 Replies)
Discussion started by: unaligned
5 Replies

6. Shell Programming and Scripting

[solved] using backticks to call bash from perl

Hi all, Here is my code: my $x = `bash -c \" ls -l filename | awk '{print \$5}'\"`; print "$x\n"; This will run the first part of the bash script but not the awk command. It therefore gives output of: -rw-r--r-- 1 root root 13619200 2012-04-25 08:16 filename I am actually trying to... (0 Replies)
Discussion started by: free2rhyme2k
0 Replies

7. Shell Programming and Scripting

run command with ssh[solved]

Hi all, Is it possible to make this possible ? $ echo $SKY_HOME /var/sink/SKY $ echo $SKY_HOME /home/smily/SKY $ ssh root@xyz "echo $SKY_HOME" root@xyz 's password: ****** /home/smily/SKY wrong output I was expecting the output as /var/sink/SKY (3 Replies)
Discussion started by: linuxadmin
3 Replies

8. Shell Programming and Scripting

[Solved] Using SSH in bash script

Hello, I am writing a script that has to log in to X number of servers over a full C class range. I am only keyed on a certain number of these servers and this can change from time to time. The part of my script that deals with this is for i in $(cat $server_list); do ssh ... (0 Replies)
Discussion started by: colinireland
0 Replies

9. Shell Programming and Scripting

[Solved] passwordless SSH not working in one direction

Hi, I am trying to remove the password requirement when connecting with SSH. I have 1 server with Solaris 10 and 1 server with Solaris 9. I have created both keys on both servers, copied public key to the other server and created a file auithorixed_keys on both. I can successfully... (4 Replies)
Discussion started by: mcclunyboy
4 Replies

10. Solaris

[Solved] SSH Query differences Solaris 9/10

Hi, I am trying to SSH without a password from a Solaris 10 box to a Solaris 9 box. I am not using root user but file permissions seem to be fine... Can anyone tell me why this might not be working?! I can successfully SSH without a password from the Solaris 9 box to the Solaris 10 box,... (0 Replies)
Discussion started by: mcclunyboy
0 Replies
Login or Register to Ask a Question