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
system not booting after running local boot scripts tcb3210 Ubuntu 0 05-30-2008 06:55 AM
mount CD from local laptop to UNIX server remotely duke0001 UNIX for Advanced & Expert Users 7 10-31-2007 04:20 PM
populate variable from remote result hcclnoodles Shell Programming and Scripting 2 02-19-2007 05:44 AM
Running an Interactive Program Remotely Terrible Shell Programming and Scripting 3 10-20-2006 12:48 AM
running commands with remotely with Telnet Terrible Shell Programming and Scripting 2 06-27-2006 05:47 PM

Closed Thread
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
  #1 (permalink)  
Old 11-19-2008
hcclnoodles hcclnoodles is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 272
running command remotely to populate local variable

If I run this


Code:
[root@central-server] # ssh remote-server 'du -sk /usr/platform/`uname -i`/'
174     /usr/platform/SUNW,Sun-Fire-V245

I get my output just fine,

However, if i try to do the same but populate a local variable within my script called for example 'result'


Code:
#!/bin/ksh

result=`ssh remote-server 'du -sk /usr/platform/`uname -i`/'`
echo $result

I get


Code:
[root@central-server] # ./test.sh 
./test.sh[13]: /: cannot execute
./test.sh[13]: -i:  not found

It looks like the `uname -i` is not getting run remotely, does anybody know how I can get this to be recognised by the remote box ?

Any help would be great

Cheers
  #2 (permalink)  
Old 11-19-2008
System Shock's Avatar
System Shock System Shock is offline Forum Advisor  
Registered User
  
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 521
Use proper korn shell command substitution in the script.

Code:
# cat script
     #!/usr/bin/ksh
     result=$(ssh remote-client 'du -sk /usr/platform/`uname -i`')
     echo $result

# ./script
448 /usr/platform/FJSV,GPUZC-M
#


Last edited by System Shock; 11-20-2008 at 10:59 AM..
  #3 (permalink)  
Old 11-19-2008
hcclnoodles hcclnoodles is offline
Registered User
  
 

Join Date: Mar 2002
Posts: 272
thankyou, i didnt know you could do that with the brackets ....is that ksh only ?

ps - works perfectly thanks
  #4 (permalink)  
Old 11-20-2008
System Shock's Avatar
System Shock System Shock is offline Forum Advisor  
Registered User
  
 

Join Date: May 2006
Location: Tau Ceti V
Posts: 521
It probably works in bash and newer shells as well.
Closed Thread

Bookmarks

Tags
shell script, shell scripting, unix scripting, unix scripting basics

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 10:17 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