Variables in paths dont get displayed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Variables in paths dont get displayed
# 1  
Old 06-08-2009
Variables in paths dont get displayed

I have a variable embedded in a path, and when I print the path, the variable name gets printed out, and not the actual value. Here is an example.

NODE='database1'
j='/home/log/$NODE/alert$NODE.log'
echo $j

Result that I got : /home/log/$NODE/alert$NODE.log

Result that I expected: /home/log/database1/alertdatabase1.log

Can someone please tell me if I am forgetting something?

Thanks,

Moe
# 2  
Old 06-08-2009
try puting it in this way
Code:
NODE=database1
j=/home/log/${NODE}/alert${NODE}.log
echo $j


Last edited by vidyadhar85; 06-08-2009 at 06:42 PM..
# 3  
Old 06-08-2009
I did put it the way you told me, and when I ran it I got this

/home/log/${$NODE}/alert${NODE}.log

it printed it the way I wrote it. Same problem.
# 4  
Old 06-08-2009
Quote:
Originally Posted by matabani
I did put it the way you told me, and when I ran it I got this

/home/log/${$NODE}/alert${NODE}.log

it printed it the way I wrote it. Same problem.
No chance buddy
which shell are you using??
and paste your code what you tried second time
# 5  
Old 06-08-2009
Its a hybrid shell thats posix compliant.

Here is the code

i='oakdrdb1 oakdrdb2'

for NODE in ${i}
do


j='/home/log/${$NODE}/alert${NODE}.log home/log/${NODE}/evmd/evmd.log'

echo "****$NODE****"
for APATH in ${j}
do
echo "Current Node: $NODE"
echo "Current Path: $APATH"
if [ `grep "ERROR" $APATH|wc -l` -gt "0" ];then

case $APATH in
"/$ORA_CRS_HOME/log/$NODE/alert$NODE.log") echo "Alert log Errors: YES";;
"/$ORA_CRS_HOME/log/$NODE/client/css$i1.log") echo "CSSD log Errors: YES";;
"/$ORA_CRS_HOME/log/$NODE/crsd/crsd.log") echo "CRSD log Errors: YES";;
"/$ORA_CRS_HOME/log/$NODE/evmd/evmd.log") echo "EVMD log Errors: YES";;
esac
else
case $APATH in
"/$ORA_CRS_HOME/log/$NODE/alert$NODE.log") echo "Alert log Errors: NO";;
"/$ORA_CRS_HOME/log/$NODE/client/css$i1.log") echo "CSSD log Errors: NO";;
"/$ORA_CRS_HOME/log/oakdrdb1/crsd/crsId.log") echo "CRSD log Errors: NO";;
"/$ORA_CRS_HOME/log/$NODE/evmd/evmd.log") echo "EVMD log Errors: NO";;
esac
fi
done

echo"";
done
# 6  
Old 06-08-2009
this is what you expecting right??
Code:
home/vidya_perl> cat vv
i="oakdrdb1 oakdrdb2"

for NODE in ${i}
do

j="/home/log/${NODE}/alert${NODE}.log home/log/${NODE}/evmd/evmd.log"
echo "$j"
echo "****$NODE****"
done

running the code
Code:
/home/vidya_perl> vv
/home/log/oakdrdb1/alertoakdrdb1.log home/log/oakdrdb1/evmd/evmd.log
****oakdrdb1****
/home/log/oakdrdb2/alertoakdrdb2.log home/log/oakdrdb2/evmd/evmd.log
****oakdrdb2****

# 7  
Old 06-08-2009
Yes.....exactly!!!!!

-----Post Update-----

However, I just noticed that your prompt is vidya_perl, so does that mean you are using perl and not unix ?

I am new in unix, so I am not quite familiar with it. Is the way to do this the same on both perl and unix ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[zenity] string is not displayed

I am trying to display a string in zenity: chars="\, /, <, >, ?, |, &, $" echo $chars \, /, <, >, ?, |, &, $ Now when I execute: zenity --forms --text="Chars not allowed: $chars" --add-entry="File Name" Instead of getting Chars not allowed: \, <, >, ?, |, &, $ I am getting Forms... (3 Replies)
Discussion started by: soichiro
3 Replies

2. SuSE

No IP address displayed in who command

when i open a terminal session of my SUSE server using puTTy and type "who am i" then it displays my local pc ip address. root@LinuxSUSE1> who am i root pts/8 2012-03-28 16:02 (192.168.134.213) But when i open a terminal session of my SUSE server using Xmanager's Xstart and type... (9 Replies)
Discussion started by: Arun_Linux
9 Replies

3. Shell Programming and Scripting

perl - output not being displayed

Hi All I have the following code sub pall_nvrm { my $cmd = `pall -w "/u/ab/scripts/dev/nvrmerros/nvrmpaller"`; print $cmd; } if i run pall -w "/u/ab/scripts/dev/nvrmerros/nvrmpaller" in a shell i get this sort of out put eagley: boxted: cadle: eabost: hales: (3 Replies)
Discussion started by: ab52
3 Replies

4. Shell Programming and Scripting

Suppressing a message from being displayed

I have a script which checks for *.txt files in a particular directory and if no files were found then it goes into sleep for 10 secs and looks back for files again and if any files were found then the script does some processing with the files found, which is my requirement too. FILE_EXISTS=`ls... (5 Replies)
Discussion started by: vpv0002
5 Replies

5. HP-UX

Search environment variables for paths

Hi, I am using the HP machine at the moment and by default I have been setup with the kron shell i.e. my home profile is .kshrc I would like to access a program anywhere on the system so I have added a path and created an environment variable like this: export myvarpath=/a/abc/def/ghij... (3 Replies)
Discussion started by: cyberfrog
3 Replies

6. Shell Programming and Scripting

password getting displayed using sudo

Hi While doing the following command password is gettin dispalyed : ssh <host> "sudo command ; exit" .... while i type my password for 2nd its gettin displayed ... i tried stty -echo and stty echo ... still i am havin problem..:confused: (1 Reply)
Discussion started by: ningy
1 Replies

7. UNIX for Dummies Questions & Answers

Date to be displayed in two digits

I want the date to be displayed in two digits. I have written a script to calculate yesterday's date. I'm getting the yesterday's date as 2009085. Desired output: 20090805 Find the script below: #!/bin/ksh ### Script to get Yesterday Date ############# Y=`date +'%Y'`... (6 Replies)
Discussion started by: venkatesht
6 Replies

8. Shell Programming and Scripting

Password is getting displayed

My shell script which runs on solaris has an execution in it. Contents of shell script BEGIN : Executable_filename username/password@DBinstance parameter2 parameter3 Contents of shell script END : When i launch the shell script, it connects to database to gets few details.. In the... (3 Replies)
Discussion started by: shafi2all
3 Replies

9. HP-UX

swlist is not displayed in HP-UX

Hi swlist command is not displayed in HP-UX ..it displays swlist: Command not found. uname -a HP-UX inccishh B.11.11 U 9000/800 4046719263 unlimited-user license :b: Best Regards vasanthan (4 Replies)
Discussion started by: vasanthan
4 Replies

10. Solaris

hostname not displayed

Hi, I posted a problem earlier on on how to change IP addresses on an E450. I was able to work around this and wanna say thanks to all who assisted. But now on my server, I get this error, trying to configure hosts..RPC timed out. Also, when I type on the command line, hostname, nothing is... (7 Replies)
Discussion started by: Ronny
7 Replies
Login or Register to Ask a Question