09-02-2008
dynamic variables
I am new to unix and the following problem is bugging me.
var1="hello1"
var2="hello2"
var3="hello3"
counter=1
while [ $counter -le 3]
do
echo $var$counter
done
the idea here is to display the value of "var" based on the counter.
I am using the korn shell. I used array here but the problem is that I am executing the script from another script and so the prompt comes as "-A bad option"
Can the above problem be done in another way i.e without using arrays.
Can eval be useful here? please help.
code snippet for this would be very helpful
TIA
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Gurus,
I have a requirement of writting the shell script where it should ask me two values
FND_TOP=/d02/app/oracle/xxx/fnd/11.5.0
CDCRM_TOP=/d02/app/oracle/xxx/cdcrm/11.5.0
and then keep these values stored as variables for the execution of rest of the script.
Because, I have to... (2 Replies)
Discussion started by: isingh786
2 Replies
2. Programming
Hi,
is it possible in C to allocate dynamically a global variable?? (3 Replies)
Discussion started by: littleboyblu
3 Replies
3. Shell Programming and Scripting
Hi All,
Shell is ksh
I've given portion of the script here to explain the problem.
It will accept 2 input parameters .
in_file1=$1
in_file2=$2
outbound_dir=/home/outbound
for i in 1 2
do
eval file$i=$outbound_dir/\$in_file$i
eval echo "filename is \$file$i"
... (4 Replies)
Discussion started by: kk17
4 Replies
4. Shell Programming and Scripting
Hi,
I need some direction with the following. The below code is semi-psuedo code which will hopefully make it easier to understand what I am trying to achieve:
for i in `echo ${testarray
}`
do
let c=c+1
eval "first$c=$i"
while... (4 Replies)
Discussion started by: yonderboy
4 Replies
5. Shell Programming and Scripting
Code:
$ cat test.bash
#!/bin/bash
job=$1
steps=$2
num=$(echo "$@" | wc -w)
Example Submission:
$ ./test.bash BS01 3 1 2 3
What: (2 Replies)
Discussion started by: mkastin
2 Replies
6. Shell Programming and Scripting
Hello,
so i'm making a script, using dynamic variables and trying to expand them. So far it hasn't worked out too well so it seems that I need some help from you, the elite.
Example:
#!/bin/sh
counter=0
until (($counter>5))
counter2=1
until (($counter2>6)); do
if ;... (5 Replies)
Discussion started by: TehOne
5 Replies
7. Shell Programming and Scripting
Greetings all,
Been trying to do my Googling and forum searches but can't seem to lock in on a solution.
I have a script that parses a log and collects all the uniq events to a flat file. Some days might have 50 unique events, other days might have 75. (Hence my reference to dynamic.)
... (2 Replies)
Discussion started by: sjrupp
2 Replies
8. Shell Programming and Scripting
Hi All,
I am really struggling to solve this problem, this might be small but I am not able to, can somebody help me?
I have few directories and these directories receives text files in large amount with in fraction of seconds. So I just want to send all the files in current directory to... (2 Replies)
Discussion started by: VasuKukkapalli
2 Replies
9. Shell Programming and Scripting
Hi all,
I want to dynamically set variables in a bash script. I made a naive attempt in a while loop that hopefully can clarify the idea.
n=0; echo "$lst" | while read p; do n=$(($n+1)); p"$n"="$p"; done
The error message is:
bash: p1=line1: command not found
bash: p2=line2: command... (8 Replies)
Discussion started by: jeppe83
8 Replies
10. Shell Programming and Scripting
Hi ,
i am unable to generate dynamic variables can any one please help me on the below issue
j=1
{record_count_"$j"}=`db2 -xselect substr\(job_name,24\) rec_count from $libname.audit_table_nrt where job_name like \'DATAMART_DEL_RUN%\' and STS_FLAG=\'E\' and seq_no=$i`
echo " record... (3 Replies)
Discussion started by: bhaskar v
3 Replies
LEARN ABOUT OPENDARWIN
dylibprof
DYLIBPROF(1) General Commands Manual DYLIBPROF(1)
NAME
dylibprof - control the shared pc sampling of a dynamic shared library
SYNOPSIS
dylibprof [-e | -d] | [-c | -r | -b | -h | -p [-o <file>] <dylib>]
DESCRIPTION
Dylibprof along with the server /usr/libexec/profileServer allows shared program counter sampling of a dynamic shared library across all
the programs that use the library.
To use dylibprof(1), /usr/libexec/profileServer must be running. So first start /usr/libexec/profileServer and leave it running in the
back ground:
% /usr/libexec/profileServer >& /dev/console &
/usr/libexec/profileServer starts up with shared pc sampling disabled. It should not be left running with shared pc sampling enabled if no
sampling is being done as every launch of a program that uses the dynamic linker is effected. This is true even to a small extent if there
no libraries being sampled.
If you need to profile from boot up for all processes then the following line can be added to /etc/bootstrap.conf:
server "/usr/libexec/profileServer" services NSProfileServer NSProfileControl;
Before any dynamic shared library can be sampled sampling must be enabled as
follows:
% dylibprof -e
It can then later be disabled when no more sampling is to be done with:
% dylibprof -d
EXAMPLE
To sample the dynamic shared library /System/Library/Frameworks/System.framework/Versions/B/System for example requires the following
steps. First create a sample buffer for the library:
% dylibprof -c /System/Library/Frameworks/System.framework/Versions/B/System
Then begin the sampling:
% dylibprof -b /System/Library/Frameworks/System.framework/Versions/B/System
After this programs launched using this library will be part of the shared pc sampling. Typically what would be done is to then use the
system normally for a number of hours.
Then to halt the sampling:
% dylibprof -h /System/Library/Frameworks/System.framework/Versions/B/System
The profiling output file (a gmon.out file) can be created with:
% dylibprof -p -o /tmp/gmon.out /System/Library/Frameworks/System.framework/Versions/B/System
Using the profiling output file and the library a profile listing and a time based order file (time.order) can be created with: gprof(1):
% gprof -S /System/Library/Frameworks/System.framework/Versions/B/System /tmp/gmon.out
When no more sampling for this library is to be done the sample buffer can be
removed with:
% dylibprof -r /System/Library/Frameworks/System.framework/Versions/B/System
The options are:
-e Enable shared program counter sampling for dynamic libraries.
-d Disable shared program counter sampling for dynamic libraries.
-c Create a pc sample buffer for the library.
-b Begin sampling for programs subsequently launched using the library.
-h Halt sampling for programs subsequently launched using the library.
-p Produce a profiling output file (a gmon.out file) for the library.
-r Remove the pc sample buffer for the library.
-o name
Use the file name instead of gmon.out when producing the profiling output file with the -p above.
FILES
gmon.out profile output file
/var/tmp/profile/profile.XXXXXX the sample buffer file
SEE ALSO
gprof(1)
Apple Computer, Inc. March 19, 2002 DYLIBPROF(1)