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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[csh] How to capture output from a command and pass it on to a variable? machinogodzilla Shell Programming and Scripting 3 05-11-2008 06:36 AM
How to pass option with "at" command? bd9439 UNIX for Dummies Questions & Answers 3 03-24-2008 01:45 PM
pass each elements in array to ssytem command jaganadh Shell Programming and Scripting 0 12-14-2007 03:57 AM
can I pass awk variable to system command? zhynxn Shell Programming and Scripting 2 07-05-2006 08:11 AM
pf not working properly even with only "pass in all" and "pass out all" rules xyyz UNIX for Advanced & Expert Users 4 12-30-2003 02:33 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-05-2006
Registered User
 

Join Date: Jul 2006
Posts: 68
Pass hotname from command

I have a problem, which is,
I have servers as
$hostname : Serverxxd
$hostname : Serverxxs
$hostname : Serverxxl
$hostname : Serverxxp
d=dev, s=sit, l=stg, p=prd
The packages will be in all the boxes and my script contains $ENV which I should be
getting from 'hostname'
I am not able to determine how I could look for the last letter in hostname and use it in script to call the ENV variable.

Please help/advise
Thanks
Chiru
Reply With Quote
Forum Sponsor
  #2  
Old 09-05-2006
Glenn Arndt's Avatar
Anomalous Lurker
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
One way --
Code:
lastletter=$(expr substr $hostname $(expr length $hostname) 1)
Reply With Quote
  #3  
Old 09-05-2006
Registered User
 

Join Date: Jul 2006
Posts: 68
Thankyou..it worked !!!
Reply With Quote
  #4  
Old 09-05-2006
Registered User
 

Join Date: Jul 2006
Posts: 183
question

Glenn,

I got a small question. How do you assign variable value with : here. What's the significance here.

Quote:
$hostname : Serverxxd
$hostname : Serverxxs
$hostname : Serverxxl
$hostname : Serverxxp
could you ever assign a varialbe value with :

Please let me know
Reply With Quote
  #5  
Old 09-05-2006
Glenn Arndt's Avatar
Anomalous Lurker
 

Join Date: Feb 2006
Location: Indianapolis, IN
Posts: 255
I think the original poster was just defining in non-programming terms what the $hostname variable could be. I don't believe the ":" has any significance beyond that.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0