Sponsored Content
Top Forums Programming How to refer to variable (korn shell)? Post 302424774 by fpmurphy on Wednesday 26th of May 2010 09:13:02 AM
Old 05-26-2010
In ksh93, a period in a variable name denotes a compound variable. Since you did not explicitly declare a compound variable, I have used regular variables.

Code:
#!/bin/ksh93

integer dvd=4
integer number=0

while (( dvd ))
do

     eval "let variable\$dvd=$number"
     print "Iteration: $dvd"
     eval print "Variable: \$variable$dvd"

     (( number++,  dvd-- ))
 
done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding Occurence of comma in a Variable ( KORN Shell)

All I want to find the occurence of comma in a variable in KORN shell. For example : var = test,test2,test3 .... finding occurence of comma in this variable. Result = 3 now. Please help me to write the code. Thanks in advance. Regards Deepak (2 Replies)
Discussion started by: DeepakXavier
2 Replies

2. Shell Programming and Scripting

how to refer one variable using another

Hi, How will you refer one variable's value using another in unix? For e.g Take the case System1_ip=172.120.20.54 And in latter part of the program while I'm using the values in a for loop I use i=System1 j=${i}_ip k=$j But K's value at the end of the run is System1_ip I want... (2 Replies)
Discussion started by: dayanandra
2 Replies

3. Shell Programming and Scripting

compound variable in korn shell

in a text " Korn Shell Unix programming Manual 3° Edition" i have found this sintax to declare a compoud variable: variable=( fild1 (0 Replies)
Discussion started by: ZINGARO
0 Replies

4. Shell Programming and Scripting

compound variable in korn shell

in a text " Korn Shell Unix programming Manual 3° Edition" i have found this sintax to declare a compoud variable: variable=( fild1 fild1 ) but this sintax in ksh and sh (HP-UNIX) not work... why?? exist another solution for this type of variable ??? (5 Replies)
Discussion started by: ZINGARO
5 Replies

5. Shell Programming and Scripting

Korn Shell Variable values difference

I am using two shell scripts a.ksh and b.ksh a.ksh 1. Sets the value +++++++++++++++++ export USER1=abcd1 export PASSWORD=xyz +++++++++++++++++ b.ksh 2. Second scripts calls sctipt a.ksh and uses the values set in a.ksh and pass to an executable demo... (2 Replies)
Discussion started by: kunalseth
2 Replies

6. Shell Programming and Scripting

Setting variable for query using iSql / Korn Shell

Hi All- First time using iSql. I have 4 query files - some have more than 1 line of sql statements After a bit of research it appears I can just use the -i command and specify the input file. Questions: Does it matter that there are multiple queries in each file? Do I need to have... (3 Replies)
Discussion started by: Cailet
3 Replies

7. Shell Programming and Scripting

korn shell: check the content of a string of a variable

hello, i have a variable which should have following content : var="value1" or var="value2" or var="value2:*" # example: value2:22 how can i check : - if the content is ok (value1 / value2* ) - the two options of "value2" when content is example "value2:22" , i want to split... (3 Replies)
Discussion started by: bora99
3 Replies

8. Shell Programming and Scripting

Korn Shell help - Using parameter to create variable names

I'm using korn shell and I am wondering if it's possible to use a parameter passed into a function to build a variable name in a configuration file. I have the function in one source file, I'd like to have a global configuration file instead of hardcoding logins to each script. So I have a... (7 Replies)
Discussion started by: mrevello
7 Replies

9. UNIX for Dummies Questions & Answers

How to import a variable Used in Another Korn Shell Script?

Hi I am using two shell scripts which are running on the system simultaneously. And in one of the script i am exporting an Integer Variable. Now i want to use the variable in another script. But i cannot run the first script in the second as the first script has many other functions which... (3 Replies)
Discussion started by: Ajesh
3 Replies

10. Shell Programming and Scripting

[Solved] How to refer more than 9 command line inputs for a scripts in korn shell?

Hi all, I have a script which should take more than 9 command line inputs while running. Likescript.sh a s d f g h j j k l o p i u y t r e w Now in the script if I have to access one of the input which is at position after 9, in this case say 'p' then how can I do that? echo $12 will not work... (15 Replies)
Discussion started by: pat_pramod
15 Replies
SG_PREVENT(8)							     SG3_UTILS							     SG_PREVENT(8)

NAME
sg_prevent - sends a SCSI PREVENT ALLOW MEDIUM REMOVAL command SYNOPSIS
sg_prevent [--allow] [--help] [--prevent=PC] [--verbose] [--version] DEVICE DESCRIPTION
Sends a SCSI PREVENT ALLOW MEDIUM REMOVAL command to DEVICE. The default action of this utility is to prevent the removing or ejecting of the medium from a drive. This is done by ignoring the SCSI START STOP UNIT command (see sg_start) and ignoring the eject button on the drive when the user presses it. Drives that hold removable disks, tape cartridges or cd/dvd media typically implement this command. The definition of the "prevent" codes for this command differ between disks and tapes (covered by SBC-3 and SSC-3) and cd/dvd drives (covered by MMC-5). The "prevent codes" described here are from MMC-5. OPTIONS
Arguments to long options are mandatory for short options as well. -a, --allow allow medium removal. This is equivalent to setting to '--prevent=2'. Cannot be used with --prevent=PC option (i.e. either use no options (hence prevent removal), this option or --prevent=PC). -h, --help output the usage message then exit. -p, --prevent=PC where PC is a prevent code value. Defined values are: 0 allows removal, 1 prevents removal (default), 2 allows persistent removal while 3 prevents persistent removal. "Persistent" in this context means that the initiator (port) that successfully uses code 3 blocks other initiators (ports) from allowing removal. A "persistent prevent" state can be cleared by the owner allowing persistent removal (code 2) or a power cycle (or anything that resets the device (lun)) or some special commands (e.g. various service actions of Persistent Reserve Out, see SPC-3). -v, --verbose increase the level of verbosity, (i.e. debug output). -V, --version print the version string and then exit. EXIT STATUS
The exit status of sg_prevent is 0 when it is successful. Otherwise see the sg3_utils(8) man page. AUTHORS
Written by Douglas Gilbert. REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>. COPYRIGHT
Copyright (C) 2004-2007 Douglas Gilbert This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. SEE ALSO
sg_start(sg3_utils), sg_persist(sg3_utils) sg3_utils-1.23 January 2007 SG_PREVENT(8)
All times are GMT -4. The time now is 06:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy