The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
remote ssh commands help jcalisi Shell Programming and Scripting 4 03-04-2009 11:39 PM
Can BASH execute commands on a remote server when the commands are embedded in shell bash_in_my_head Shell Programming and Scripting 1 12-04-2008 01:51 AM
commands to remote sftp chm0dvii Shell Programming and Scripting 0 08-07-2008 07:23 PM
display remote commands ndegem SUN Solaris 4 01-23-2008 12:24 PM
Remote commands problem using RSH & Rexec fhuwaidy UNIX for Advanced & Expert Users 0 01-15-2008 04:22 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-15-2009
Wrathe Wrathe is offline
Registered User
  
 

Join Date: Jun 2008
Posts: 6
Post SSH, Remote Commands and echo, oh my!

So, HostB has a SSH trust via pre-shared keys from HostA.

HostA> ssh HostB hostname
HostB

HostA> ssh HostB echo `hostname`
HostA

HostA> ssh HostB 'echo `hostname`'
`hostname`

HostA> ssh HostB "echo `hostname`"
HostA

HostA> ssh HostB echo $PS1
user@HostA:$PWD

HostA> ssh HostB 'echo $PS1'
$PS1


I'm at a loss for how to get these types of commands to run remotely. Echo seems to always interpret locally.

sshd_config is setup for PermitRootLogin forced-commands-only.

The authorized_keys is setup for command=$SSH_ORIGINAL_COMMAND ssh-dss <key> user@HostA

Just including that in case it's somehow causing my grief, though it seems more like quoting, trapping, etc.

The idea is this will be used on many systems to run a command, and it'd be nice to be able to prefix returns w/ a hostname for example.

Locally, I could run:

echo "`hostname`: `df -g /tmp|tail -1`"

and get

HostA : /dev/hd3 16.00 4.06 75% 7655 1% /tmp

So that way, if I script to run against a large amount of hosts, I get a hostname prefix for easy output reading.

Though the redirect also brings up another question.

If I do

HostA> ssh HostB cat /etc/passwd|grep user
user::100:100:<snip>

Is the grep happening remotely, or is the grep happening locally after the data is returned?

Thanks in advance for any insight you can offer.
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0