The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > AIX
.
google unix.com



AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Bash: bad substitution problem...pls help! xfouxs UNIX for Dummies Questions & Answers 1 11-23-2007 05:48 PM
Substitution problem. er_ashu Shell Programming and Scripting 3 04-03-2007 07:48 AM
ksh substitution solea Shell Programming and Scripting 2 08-09-2004 05:30 AM
bad substitution problem (easy question) champion UNIX for Dummies Questions & Answers 10 07-01-2002 11:16 PM
Substitution using sed Ohji UNIX for Dummies Questions & Answers 3 08-17-2001 11:32 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-09-2008
gravy26 gravy26 is offline
Registered User
  
 

Join Date: Oct 2007
Location: Ct
Posts: 15
VI Substitution problem

I'm having a problem getting my variables to work in dishing out an RMC script.

The $1 works fine. $2 does not
Here's a portion of the script:

server=$1
filesystem1=$2
#
dsh -w $1 'mkcondition -c "/var space used" -s "Name == \"$2\"" -e "PercentTotUsed > 90" -d "An event will be generated when more than 90 percent" -E "PercentTotUsed < 85" -D "The event will be rearmed when the percent of the space used in the $2 directory falls below 85 percent." "$2 space 90% used"'
#
The cmd entered on the cmd line is

./mkcondition techserv /testfs1Here is the output
server=$1
filesystem1=$2
+ filesystem1=/testfs1
filesystem2=$3
+ filesystem2=
filesystem3=$4
+ filesystem3=
#
echo $2
+ echo /testfs1
/testfs1
#
dsh -w $1 'mkcondition -c "/var space used" -s "Name == \"$2\"" -e "PercentTotUsed > 90" -d "An event will be generated when more than 90 percent" -E "PercentTotUsed < 85" -D "The event will be rearmed when the percent of the space used in the $2 directory falls below 85 percent." "$2 space 90% used"'
+ dsh -w techserv mkcondition -c "/var space used" -s "Name == \"$2\"" -e "PercentTotUsed > 90" -d "An event will be generated when more than 90 percent" -E "PercentTotUsed < 85" -D "The event will be rearmed when the percent of the space used in the $2 directory falls below 85 percent." "$2 space 90% used"
#

Any suggestions would be greatly appreciated. __._
  #2 (permalink)  
Old 02-11-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,568
Why \"$2\" ? (the backslashes puzzles me, I dont understant what you are up to with them, there will be no substitution to the value of $2 is that what you want?)
  #3 (permalink)  
Old 02-11-2008
gravy26 gravy26 is offline
Registered User
  
 

Join Date: Oct 2007
Location: Ct
Posts: 15
Thanks for replying.
The "Name == \"$2\"" is part of the mkcondition command structure in RMC.

And the quotes and backslashes are what's failing my substitution...grrr..

I've tried hundred different ways but cant get it to substitute..

Mike M.
  #4 (permalink)  
Old 02-11-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,568
Im (more..) awake now... forget my previous post...
theres nothing wrong with your double quotes... I wonder if its not the single quotes giving you trouble...

Just thoughts...
  #5 (permalink)  
Old 02-11-2008
gravy26 gravy26 is offline
Registered User
  
 

Join Date: Oct 2007
Location: Ct
Posts: 15
I agree they could be, but the single quotes are needed when dsh'ing out from the control work station.

Mm.
  #6 (permalink)  
Old 02-12-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,568
My suggestion is:

#Here:
dsh -w $1
#You are lets say on server1 and so it knows of $1 therefore substitutes

'mkcondition -c "/var space used" -s "Name == \"$2\"" -e "PercentTotUsed > 90" -d "An event will be generated when more than 90 percent" -E "PercentTotUsed < 85" -D "The event will be rearmed when the percent of the space used in the $2 directory falls below 85 percent." "$2 space 90% used"'
# Here you are on remote server $1... how does he know of $2 ? so I believe $2 is substituted to ""

Have you tried to export $1 $2 before dsh (thats 6 years now I havent touched dsh, was a time when I was responsible of a SP2...) but I may be saying a load of nonsense and should stay home (not well bu 2 collegues are of ill...)
  #7 (permalink)  
Old 02-12-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
The "$2" will be resolved, because variables are expanded prior to the execution of a command (see "command evaluation in the Korn shell" - to change the default behaviour is what "eval" is for, yes?) .

The problem is that the "$2" is inside single quotes, which will prevent evaluation of the variable:

Code:
# var="hello there"
# print $var
hello there
# print "$var"
hello there
# print '$var'
$var
Making the variable $2 expand is a bit cumbersome, it goes like that:

Code:
var="there"
# print 'hello '"$var"'.'
hello there.
Quote:
vbe said:
(thats 6 years now I havent touched dsh, was a time when I was responsible of a SP2...)
ahh, the good old days of PSSP 2.1 and 2.2 - before IBM came up with that "perspectives"-crap......

I hope this helps.

bakunin
Sponsored Links
Closed Thread

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:02 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