Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Need help with repeating variables in a shell script Post 302760721 by Corona688 on Thursday 24th of January 2013 01:17:07 PM
Old 01-24-2013
Quote:
Originally Posted by ricco19
Basically, the program needs to sit in terminal forever waiting for a keystroke. After an initial keystroke, it needs to wait a very short amount of time (1/10th of a second in this case) for another keystroke. If no keystroke is registered in that short time, it echos the output (which will be piped with sed commands), and restarts.
Hmmm.

I think a terminal device can do that all by itself without bash's help, actually! From man termios:

Code:
       In non-canonical mode input is available immediately (without the  user
       having  to  type  a line-delimiter character), and line editing is dis-
       abled.  The settings of MIN (c_cc[VMIN]) and TIME (c_cc[VTIME])  deter-
       mine  the  circumstances  in  which a read(2) completes; there are four
       distinct cases:

       * MIN == 0; TIME == 0: If data is available,  read(2)  returns  immedi-
         ately,  with the lesser of the number of bytes available, or the num-
         ber of bytes requested.  If no data is available, read(2) returns 0.

       * MIN > 0; TIME == 0: read(2) blocks until the lesser of MIN  bytes  or
         the  number  of bytes requested are available, and returns the lesser
         of these two values.

       * MIN == 0; TIME > 0: TIME specifies the limit for a timer in tenths of
         a  second.   The  timer  is  started when read(2) is called.  read(2)
         returns either when at least one byte of data is available,  or  when
         the  timer  expires.  If the timer expires without any input becoming
         available, read(2) returns 0.

       * MIN > 0; TIME > 0: TIME specifies the limit for a timer in tenths  of
         a second.  Once an initial byte of input becomes available, the timer
         is restarted after each further byte is  received.   read(2)  returns
         either  when  the lesser of the number of bytes requested or MIN byte
         have been read, or when the inter-byte timeout expires.  Because  the
         timer  is  only  started after the initial byte becomes available, at
         least one byte will be read.

I'll see if I can build something quick.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script Variables

HI guys I need to store the output of a sql query in a variable, can you tell me how to do that eg) select count(*) from s_escl_req $count = count(*) from s_escl_req how would i store the count(*) from the sql statement in a variable called $count. thanks (3 Replies)
Discussion started by: ragha81
3 Replies

2. Shell Programming and Scripting

Repeating variables in the code

Hi all, I had written 3 KSH scripts for different functionalities. In all these 3 files there are some 30 variables in common. So I want to reduce the code by placing these variables in a common properties file named (dataload.prop/dataload.parms/dataload.txt) or txt file and access it... (1 Reply)
Discussion started by: mahalakshmi
1 Replies

3. Shell Programming and Scripting

Accessing variables of one shell script in another shell script

I have a variable $exe in a shell script file a.sh which I need to access in another shell script file b.sh. How can I do that? :rolleyes: Thanks!! (2 Replies)
Discussion started by: looza
2 Replies

4. Shell Programming and Scripting

Accessing variables of one shell script in another shell script

Hi All, I have a shell script called sample1.sh where I have 2 variables. Now I have another shell script called sample2.sh. I want the variables in sample1.sh to be available to sample2.sh. For example. In sample1.sh I am finding the sum of 2 numbers namely a and b. Now I want to access... (2 Replies)
Discussion started by: rsendhilmani
2 Replies

5. Shell Programming and Scripting

Variables in shell script

mysqldump --compact --add-drop-table -h192.168.150.80 -uroot -p somePass $combined | sed '/$combined/$table/g' | mysql $databaseThe sed part is not working from the above statement. The variables combined and table are already defined and instead of showing the actual variable, it is executing the... (4 Replies)
Discussion started by: shantanuo
4 Replies

6. Shell Programming and Scripting

Shell script to extract data in repeating tags from xml

Hi, I am new to shell scripting. I need to extract data between repeating tags from an xml file and store the data in an array to process it further. <ns1:root xmlns:ns1="http://example.com/config"> <ns1:interface>in1</ns1:interface> <ns1:operation attribute1="true" attribute2="abd"... (2 Replies)
Discussion started by: sailendra
2 Replies

7. UNIX for Dummies Questions & Answers

Adding variables to repeating strings

Hello, I want to add a letter to the end of a string if it repeats in a column. so if I have a file like this: DOG001 DOG0023 DOG004 DOG001 DOG0023 DOG001 the output should look like this: DOG001-a DOG0023-a DOG004 DOG001-b (15 Replies)
Discussion started by: verse123
15 Replies

8. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

9. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

10. Shell Programming and Scripting

Shell script to create runtime variables based on the number of parameters passed in the script

Hi All, I have a script which intends to create as many variables at runtime, as the number of parameters passed to it. The script needs to save these parameter values in the variables created and print them abc.sh ---------- export Numbr_Parms=$# export a=1 while do export... (3 Replies)
Discussion started by: dev.devil.1983
3 Replies
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 06:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy