Sponsored Content
Full Discussion: Bash INKEY$ function...
Top Forums UNIX for Dummies Questions & Answers Bash INKEY$ function... Post 302785887 by wisecracker on Tuesday 26th of March 2013 01:49:02 PM
Old 03-26-2013
Hi rbatte1...

Quote:
Originally Posted by rbatte1
What's wrong with
Code:
stty raw -echo
inkey=`dd bs=1 count=1 2>/dev/null`
stty -raw echo

It is NOT a callable one liner function?

;o)

Thanks to Corona688 and his knowledge...

Here we go a single line function:-

Code:
#!/bin/bash

inkey() { char="" ; stty -icanon min 0 time 1 ; char=`dd count=1 2>/dev/null` ; }

while true
do
	printf "Some prompt:- "
	# This is LET char$=INKEY$...
	inkey
	printf "Key pressed:- '$char'...\n"
	if [ "$char" == "q" ]
	then
		printf "Quitting... \n"
		break
	fi
	if [ "$char" == "" ]
	then
		printf "Timeout works OK...\n"
	fi
	if [ "$char" == "b" ]
	then
		printf "Barry Walker...\n"
	fi
done

Bazza...

Last edited by wisecracker; 03-26-2013 at 03:05 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need assistance with bash function

Hi all! I need a little help with an imbedded fuction I am trying to write. What I am trying to do is go to a series of hosts and get the contents of an XML file, storing some of the data, along with the name of the host it was gathered from. My intent is to store this in an array for later... (1 Reply)
Discussion started by: _jade_
1 Replies

2. Shell Programming and Scripting

Need help in using power function in Bash

Hi, I would like to use a power function in Bash in an awk '{ } . e.g pow(2,3)=8 Any suggestion? I try to find online resources but most of them stated by using BC. Please advise. Thanks. (3 Replies)
Discussion started by: ahjiefreak
3 Replies

3. Shell Programming and Scripting

bash search function

I want to have a function with a similar interface: search *.cpp asdf that will search recursively all directories for *.cpp file, containing line 'asdf' inside. I tried this: function search { find . -name "$1" | xargs grep -li $2; } But it doesn't work all the time. For example, if i run it... (3 Replies)
Discussion started by: doze
3 Replies

4. Shell Programming and Scripting

[Bash]Function returning a boolean

Hello all, I would like to know if it is possible to return a the result of a boolean expression from a function like this function() { # some code return || } and what will be the return value ? Thank you for help. (6 Replies)
Discussion started by: dolphin06
6 Replies

5. Shell Programming and Scripting

In bash getting weird output from function ?

My script- result="" times() { echo "inside the times function" result=8 echo "Inside function $result" return $result } result=$(times) echo "the value is "$? echo "the value of result $result" when I run I get this, why the value still remain 0. $ ./func the value is 0 the value... (5 Replies)
Discussion started by: boy18nj
5 Replies

6. Shell Programming and Scripting

BASH function error

Hey everyone. I am currently testing my first function based BASH script. The ultimate goal is going to be moving logs from point A to point B (or if B is down, to point C). Part of this involves the following function: function testAlive{ ping -c 1 -q $1 } Now when I run ping -c... (1 Reply)
Discussion started by: msarro
1 Replies

7. Shell Programming and Scripting

Bash function

startvm() { startguest } Is there a way use one line to get this ? actually I want startvm=startguest (5 Replies)
Discussion started by: yanglei_fage
5 Replies

8. Shell Programming and Scripting

Yes or No selection within bash function

I need to add a selection within the bash function below and am having some trouble doing so. phox2b() { printf "\n\n" printf "What is the id of the patient getting Phox2B analysis : "; read id printf "Is this an intronic variant? Y/N "; read match_choice case... (5 Replies)
Discussion started by: cmccabe
5 Replies

9. Shell Programming and Scripting

Bash function, for BSD

I am putting this thread to shell-threads, because it is about how to make a function work properly. I need a hint for declaring a function right, it has been more than a year I did not work that straight with bash. So my aim is to turn off the eth0 (as it would be in linux, and bge0 in bsd ),... (2 Replies)
Discussion started by: 1in10
2 Replies

10. Shell Programming and Scripting

Bash function problem

I am trying to figure out why I am having a "problem" with some functions in a bash script I am running. The reason for air quoting is that the functions are working, they are just not displaying anything to screen when called from another function. Here's an example: function Create_Input {... (6 Replies)
Discussion started by: dagamier
6 Replies
BRANDY(1)						      BBC BASIC V interpreter							 BRANDY(1)

NAME
brandy - a portable BBC BASIC V interpreter SYNOPSIS
brandy [-help] [-size SIZE] [-lib FILENAME] [-load FILENAME] [-path DIRECTORY[,DIRECTORY]...] [-quit FILENAME] [-chain FILENAME] [-ignore] [FILENAME] DESCRIPTION
Brandy is an interpreter for BBC BASIC V, the dialect of BASIC that Acorn Computers supplied with their ranges of desktop computers that use the ARM processor such as the Archimedes and Risc PC, and is still in use on these and compatibles. BASIC V is a much extended version of BBC BASIC. This was the BASIC used on the 6502-based BBC Micro that Acorn made during the 1980s. OPTIONS
-help Print a summary of these options. -size SIZE Set the size of the Basic workspace to SIZE bytes when starting the interpreter. The minimum size allowed is 10000 bytes and any- thing below this value will be set to it. The maximum size is limited only by the environment in which the program is being run. The size may have a suffix of k to denote that the size is in kilobytes or m if it is in megabytes. For example, -size 100k will set the workspace size to 100 kilobytes (102400 bytes) and -size 8m will set it to eight megabytes (8388608 bytes). -lib FILENAME Load Basic library FILENAME when the interpreter starts. This option can be repeated as many times as required to load a number of libraries. This is equivalent to typing INSTALL "FILENAME" at the interpreter's command line. The libraries are loaded in the order given on the command line. Note that the search order is the reverse of this. -load FILENAME Load Basic program FILENAME when the interpreter starts. -path DIRECTORY[,DIRECTORY]... This specifies a list of directories that the interpreter will search when looking for libraries and programs. The directory names are separated by commas. The pseudo-variable FILEPATH$ is set to this value. -quit FILENAME Load and run the Basic program FILENAME. Leave the interpreter when the program has finished running. -chain FILENAME Load and run the Basic program FILENAME. Remain in the interpreter when the program has finished running. -graphics Start the interpreter with the screen in graphics mode in versions of the program which support graphics and the screen can be in either text or graphics modes. -ignore Ignore certain `unsupported feature' errors. By default the interpreter reports an error whenever it comes across a BASIC V feature that it does not support. This option allows some unsupported features that do not affect the basic running of the program to be ignored. FILENAME This is exactly equivalent to -chain. The case of the names of the options is ignored. It depends on the operating system under which the interpreter is running as to whether the names of files are case sensitive or insensitive. FILES
brandy executable /usr/share/doc/brandy/examples example BASIC programs SEE ALSO
/usr/share/doc/brandy full documentation Brandy's home page http://jaguar.orpheusweb.co.uk/branpage.html There is some very useful documentation for the BBC Micro available on the Internet. One very good site is The BBC Lives! at: http://www.nvg.ntnu.no/bbc/ or see http://sourceforge.net/projects/brandy/ AUTHOR
David Daniels, with contributions from Darren Salt and Colin Tuckley REPORTING BUGS
Report bugs to the bug tracker at http://sourceforge.net/projects/brandy COPYRIGHT
Copyright (c) 2000, 2001 David Daniels. Copyright (c) 2009, 2012 Colin Tuckley. This is free software; see the source for copying condi- tions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. brandy 1.20pre5 10 Jun 2012 BRANDY(1)
All times are GMT -4. The time now is 06:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy