VI Substitution problem


 
Thread Tools Search this Thread
Operating Systems AIX VI Substitution problem
# 1  
Old 02-09-2008
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  
Old 02-11-2008
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  
Old 02-11-2008
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  
Old 02-11-2008
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  
Old 02-11-2008
I agree they could be, but the single quotes are needed when dsh'ing out from the control work station.

Mm.
# 6  
Old 02-12-2008
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  
Old 02-12-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Variable substitution problem

HI i was studying about variable substitution. below are info which was given in a online tutorial. ${parameter:-word}---> If parameter is null or unset, word is substituted for parameter. The value of parameter does not change. ${parameter:=word}---> If parameter is null or... (3 Replies)
Discussion started by: scriptor
3 Replies

2. Shell Programming and Scripting

Problem with process substitution

i have tried process substitution, but run in some problems. this works: samtools view -h $SAMdir/$b.bam | htseq-count -m union -s no -q -t exon -i gene_id - $gtf > $b.count & but this not: htseq-count -m union -s no -q -t exon -i gene_id <(samtools view -h $SAMdir/$b.bam) $gtf >... (7 Replies)
Discussion started by: dietmar13
7 Replies

3. Shell Programming and Scripting

Problem with substitution in sed??

Hi alll I have a file with this content ale,AAM,id2_1_2_1_1,23,2013-01-30,1,1 ale,BAND,id2_1_1_1_1,31,2013-01-28,1,1 ale,CAI,id2_1_1_1_1,23,2013-01-28,1,1 ale,CAI,id2_1_1_1_4,23,2013-01-28,1,1 ale,CAI,id2_1_2_1_1,23,2013-01-30,2,1 ale,NAST,id2_1_1_1_1,23,2013-01-29,1,1... (1 Reply)
Discussion started by: nikhil jain
1 Replies

4. Shell Programming and Scripting

sed substitution problem

I'm writing my first script and I have all the other commands I'm using working properly, but I'm having one final issue with a sed. I've looked on the forums for some answers, which have been close but sed is quite confusing to me. My problem is that I have a file called CylinderAtom1.txt... (3 Replies)
Discussion started by: 1Aegis1
3 Replies

5. Shell Programming and Scripting

Another substitution problem

Hello again, I'm trying to change the following line: INSERT INTO PH1_TX_LOAD VALUES ('TX-78731-AABSS:4182-4','RH: GUIDE TO TENNIS',TO_DATE('18-JUN-2001:00:00:00', 'DD-MON-YYYY:HH24:MI:SS'),TO_DATE('21-JUN-2001:00:00:00', 'DD-MON-YYYY:HH24:MI:SS'),500) so that any TO_DATE is taken... (6 Replies)
Discussion started by: user_invalid
6 Replies

6. Shell Programming and Scripting

problem in dollar substitution

Hi, I have a problem in dollar substitution:- $ csv1="first_csv" $ csvnumber=1 $ echo {csv$csvnumber} {csv1} $ echo "${csv$csvnumber}" bad substitution I want first_csv...why is it not working thanks (2 Replies)
Discussion started by: scripter12
2 Replies

7. Shell Programming and Scripting

Crontab command substitution problem

Hi all, I am using Ubuntu 8.04 Linux. I have a cron job entry to run a shell script at a scheduled time. This script has a X application to be launched. As cron does not pick already exported environment variables and it runs in a separate environment, I need to export the DISPLAY variable to... (9 Replies)
Discussion started by: royalibrahim
9 Replies

8. Shell Programming and Scripting

sed substitution problem

Can anyone please help me on this. i have a file with lines say X X3200 X X X X2400 X X4100 I want to use sed to put the numbers in braces. the output should be like, X X(3200) X X X X(2400) X X(4100) (7 Replies)
Discussion started by: diliphp
7 Replies

9. Shell Programming and Scripting

Problem with sed string substitution

Hi, heres my problem: echo "aaaa(aaaa(aaa" | sed 's/a.*(//g' gives aaa but it should give aaaa(aaa .*( should find any string to the appearance of (, but it finds any string to the last appearance, any idea why, and how to do this? and what if the string ist... (2 Replies)
Discussion started by: funksen
2 Replies

10. Shell Programming and Scripting

Substitution problem.

Hi, Just need some help in this. Suppose there is one file a.txt, which contains this data: "25187","00000022","00",28-MAR-2007,"" ,"D",-000001550,+0000000000,"C", ,+000000000,+000000000,000000000,"2","" ,29-MAR-2007 613TB.STEXTRF1 "25187","0000004H","00",29-MAR-2007,""... (3 Replies)
Discussion started by: er_ashu
3 Replies
Login or Register to Ask a Question