Sponsored Content
Full Discussion: control variables...
Top Forums Shell Programming and Scripting control variables... Post 302385079 by Lock3 on Thursday 7th of January 2010 04:03:13 AM
Old 01-07-2010
control variables...

Hi.

IŽve a question to a running script:

Code:
i=0                                                                                                                                    #fill an Array with all files in a folder ending with .sys
for Par in *.sys ; do
    Par2[$i]="$Par" ;
    i=$((i + 1)) ;
done
 
#fill the "control variable" with the value of the Array
a=${Par2[0]} ; b=${Par2[1]} ; c=${Par2[2]}; d=${Par2[3]}; e=${Par2[4]}; f=${Par2[5]}; g=${Par2[6]}; h=${Para[7]}; i=${Par2[8]}; 
 
#remove the file extension (.sys) for each control variable (a,b,c,...)
a=`echo $a | sed 's/\(.*\).sys/\1/'` ; b=`echo $b | sed 's/\(.*\).sys/\1/'` ; c=`echo $c | sed 's/\(.*\).sys/\1/'`; #...
 
echo "simulation models"
echo "---------------------------------------"
echo " $a "
echo " $b "
echo " $c "
#...
echo " $i "
sleep 2
 
        echo " ++---------------------------------+"
        echo " || 01 (TI+MM) --> calculate all (a-i)"  
        echo " || 02 (TI+MM) --> calculate $a   "
        echo " || 03 (TI+MM) --> calculate $b   "
        echo " || 03 (TI+MM) --> calculate $c   "
        #...
        echo " || 09 (TI+MM) --> calculate $i   "
 
   read ANTW
   case $ANTW in
 
01) command1
02) command2
03) command3
#...
09) command 9
 
 
esac

The script works, but its really big and i think that it can rephrase in a better way retaining the functions unchanged.
Another problem is, that the variables in my script go from a to i. So if there are for example 50 .sys-files in the folder it ignores the last 41.

IŽll be glad for each advice...

Thanks a lot
Lock3
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

naming variables with variables

Hello, FIRST QUESTION: I am writing a script in which a query is taken at the beginning of the script to be later used at the end. In the query, variables are generated from a loop, and I would like to assign the variable NAME (not value) with an appended 1, 2, 3, 4.....n. The number of... (2 Replies)
Discussion started by: Allasso
2 Replies

2. Programming

How to convert byteArray variables to HexaString variables for Linux?

Hello everybody, I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Discussion started by: ritesh_163
2 Replies

3. UNIX for Dummies Questions & Answers

Using Variables for Bandwidth control

Hi, I am very new to scripting and have a question regarding variables and their use in a bandwidth monitoring script. I have identified a few primary variables being; Bandwidth CIR Download=32kbits <- these match as per the script below Bandwidth PIR Download=96kbits Bandwidth CIR... (1 Reply)
Discussion started by: vinnir
1 Replies

4. Shell Programming and Scripting

control click variables

I want to be able to control click (Mac) and be able to select from a context menu...run file....and have it dynamically run based on the control click. How do I get the control click absolute path of the filename? Are there different variables like directory, fullpath, extention? (0 Replies)
Discussion started by: mainegate
0 Replies

5. UNIX for Dummies Questions & Answers

For loop control with two variables in csh shell

Hi All How can i control for loop with two different variables in csh shell Regards Nikhil (1 Reply)
Discussion started by: Nikhilindurkar
1 Replies

6. Shell Programming and Scripting

Running a script with multiple variables like 25 variables.

Hi All, i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way?? #!/bin/ksh ##script is sample.ksh age=$1 gender=$2 class=$3 . . .... (3 Replies)
Discussion started by: Lakshman_Gupta
3 Replies

7. Shell Programming and Scripting

BASH arrays and variables of variables in C++

Sometimes it is handy to protect long scripts in C++. The following syntax works fine for simple commands: #define SHELLSCRIPT1 "\ #/bin/bash \n\ echo \"hello\" \n\ " int main () { cout <<system(SHELLSCRIPT1); return 0; } Unfortunately for there are problems for: 1d arrays:... (10 Replies)
Discussion started by: frad
10 Replies

8. Shell Programming and Scripting

Reading control characters into variables

Hi, I am trying to write a shell script to help with some digital signature work currently being undertaken where we have a file that contains a number of rows ending with ^M. What I need to do is concatenate this using shell scripting and retain the control character. E.G. abc^M... (5 Replies)
Discussion started by: chris01010
5 Replies

9. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

10. UNIX for Dummies Questions & Answers

How to pass variables into anothother variables?

Below are three variables, which I want to pass into variable RESULT1 username1=userid poihostname1=dellsys.com port1=8080 How can I pass these variables into below code... RESULT1=$((ssh -n username1@poihostname1 time /usr/sfw/bin/wget --user=sam --password=123 -O /dev/null -q... (4 Replies)
Discussion started by: manohar2013
4 Replies
echo(3XCURSES)						  X/Open Curses Library Functions					    echo(3XCURSES)

NAME
echo, noecho - enable/disable terminal echo SYNOPSIS
cc [ flag... ] file... -I /usr/xpg4/include -L /usr/xpg4/lib -R /usr/xpg4/lib -lcurses [ library... ] c89 [ flag... ] file... -lcurses [ library... ] #include <curses.h> int echo(void); int noecho(void); DESCRIPTION
The echo() function enables Echo mode for the current screen. The noecho() function disables Echo mode for the current screen. Initially, curses software echo mode is enabled and hardware echo mode of the tty driver is disabled. The echo() and noecho() functions control soft- ware echo only. Hardware echo must remain disabled for the duration of the application, else the behavior is undefined. RETURN VALUES
Upon successful completion, these functions return OK. Otherwise, they return ERR. ERRORS
No errors are defined. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
getch(3XCURSES), getstr(3XCURSES), initscr(3XCURSES), libcurses(3XCURSES), scanw(3XCURSES), attributes(5), standards(5) SunOS 5.11 5 Jun 2002 echo(3XCURSES)
All times are GMT -4. The time now is 01:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy