02-23-2005
shell variable access
Hi
I want to do the following:
1. Create a number of Gloabla varibale "ROUTE_IP_xx" based on a counter. As xx sould be from 1-10.
ie ROUTE_IP_1
ROUTE_IP_2
.
.
ROUTE_IP_10
2. I want to initalize all of these variable to 0.0.0.0
ie ROUTE_IP_1='0.0.0.0'
3. I want to be able to access this global variable through out the code.
ie $ROUTE_IP_1
Following is waht I have got. I have generated the GLOBAL variable properly. But I could not figure out how to access them.
Please let me know if you have any suggestion?
Thanks,
Sabina
#!/bin/sh
ROUTE_MAX_NO_OF_ENTRY=10
count=1
while [ $count -le $ROUTE_MAX_NO_OF_ENTRY ]
do
ip_addr=ROUTE_IP_${count}
echo "ip_addr $ip_addr"
export $ip_addr='0.0.0.0'
tmp=`echo '$'$ip_addr`
echo $tmp
count=`expr $count + 1`
done
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
hi
i have a function
abc()
{
a=1
b=2
c=3
}
Now i want to assign these values to the variables out side the function
k=a
l=b
m=c
please help (4 Replies)
Discussion started by: satish@123
4 Replies
2. Programming
I am working on garbage collector in C?
How should :confused: I find the part of heap where the variable are stored. It there any compiler (GCC) support for this. (2 Replies)
Discussion started by: amit gangarade
2 Replies
3. Shell Programming and Scripting
I have a while loop like this
cat ${filename} | while read fileline
do
...
done
I need to access a variable value $newfile inside this while loop
How will i do that?? (6 Replies)
Discussion started by: codeman007
6 Replies
4. Shell Programming and Scripting
I am unable to access the value set inside the loop from outside loop .
Thought of taking this to forum , I had seen other replies also , where a pipe takes the execution to another shell and mentioned thats the reason we do not get the variable outside loop . But I am getting an issue and I am... (1 Reply)
Discussion started by: Armaan_S
1 Replies
5. Shell Programming and Scripting
I am writing a shell script using the korn shell. It seems that I am only
able to use local variables within a while loop that is reading a file.
(I can't access a variable outside a previously used while loop.) It's been
a while since I wrote shell scripts. Here is a sample
cat file.txt... (4 Replies)
Discussion started by: ricardo.ludwig
4 Replies
6. Shell Programming and Scripting
Hi,
I had written shell script to access config file as input parameter.
Contents of ConfFile.cfg are
USER=ora
PASSWORD=ora
Shell script is DBConnect.ksh
#!/bin/sh
usage="`basename $0` <configuration_file_name>"
DB_Connect()
{
sqlplus -s ora/ora << EOF
CREATE TABLE TBL1... (10 Replies)
Discussion started by: Poonamol
10 Replies
7. Shell Programming and Scripting
Hi,
I have two scripts say one.sh and two.sh.
I want one.sh to continuously export a variable in loop. and when two.sh starts then it should read the last value exported from one.sh.
file: one.sh
#! bin/sh
for i in `seq 1 1 4000000`; do
export VAR=$(($i**$i)) ;
done
file two.sh
... (2 Replies)
Discussion started by: bhushan123
2 Replies
8. Shell Programming and Scripting
I have shell script which will try to login to SQL Plus and retrieve some data, based on the outcome i will proceed further
Below is the content of the file
pebblz02% cat test1.ksh
#! /bin/ksh
dummyvar=`sqlplus -S csm_admin/csm_admin@SIDNAME <<EOF echo hi; exit; EOF`
Error message on... (0 Replies)
Discussion started by: kiranlalka
0 Replies
9. AIX
Hi all,
I'm using AIX v 5.3
I want to create system users to access through ftp or sftp and restrict those users into specific directory and don't traverse the whole file system just to be restricted within a directory and don't get shell access . i don't want to use any other third party... (7 Replies)
Discussion started by: h@foorsa.biz
7 Replies
10. Shell Programming and Scripting
Hi all, Please help me on my problem.
I want to take a value of variable which the variable is in other file.
variable.sh
wesly=1
wina=2
wekin=3
variabletaker.sh
source variable.sh
echo $wesly
when i run the variabletaker.sh
the error result is like here
error (3 Replies)
Discussion started by: weslyarfan
3 Replies
suspend(1) User Commands suspend(1)
NAME
suspend - shell built-in function to halt the current shell
SYNOPSIS
sh
suspend
csh
suspend
ksh
suspend
DESCRIPTION
sh
Stops the execution of the current shell (but not if it is the login shell).
csh
Stop the shell in its tracks, much as if it had been sent a stop signal with ^Z. This is most often used to stop shells started by su.
ksh
Stops the execution of the current shell (but not if it is the login shell).
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
csh(1), kill(1), ksh(1), sh(1), su(1M), attributes(5)
SunOS 5.10 15 Apr 1994 suspend(1)