Visit Our UNIX and Linux User Community

Full Discussion: Select Command - return
Top Forums UNIX for Dummies Questions & Answers Select Command - return Post 302752111 by spacebar on Saturday 5th of January 2013 04:28:19 PM
Old 01-05-2013
This is a simple menu script I put together that might help you accomplish what your trying to do, It doesn't require the user to press return and it stays at top of screen:

# Script:
# Descr:  Example of auto record advance(i.e. carriage return) with simple menu

function _choices
{ clear
  cat <<BOX

     HANDY INFO - Choose Desired Number
  1  Current Directory
  2  Your Login ID
  3  UNIX Processes for your ID
  4  Entry in /etc/passwd for your ID
  5  Users with ID of 0 (zero)
  6  Users with ID >= 500
  7  ID Search PATH for $LOGNAME
  8  Currently Mounted devices
  9  HD Usage and mount-points

  0  Exit

} # EOF  _choices()

function _action
  stty raw
  ans=`dd bs=1 count=1 2>/dev/null`
  eval $1='$ans'
  stty cooked
} # EOF  _action()

function _complog
{ # Required argument: $1 = output of logname command
  if [[ "${1}" != "${LOGNAME}" ]]
    echo "\bYour Login ID is: \"${1}\" (real) and \"${LOGNAME}\" (su)."
    echo "\bYour Login ID is: \"${1}\"."
} # EOF  _complog

function _waiter
{ echo "\nPress <Enter> to continue.... \c"
  read waiting4u
} # EOF  _waiter()

function _yourc
  case "${ans}" in  # process response
    1) echo "\bThe current directory is: \c"; pwd; _waiter ;;
    2) _complog "${user}"; _waiter ;;
    3) echo "\b\b"; ps -ef | grep "${user}" | more ; _waiter ;;
    4) echo "\b\b"; grep "${user}" /etc/passwd; _waiter ;;
    5) echo "\b\b"; awk -F":" '$3 == 0 {print $0}' /etc/passwd; _waiter;;
    6) echo "\b\b"; awk -F":" '$3 >= 500 {print $0}' /etc/passwd | more ; _waiter;;
    7) echo "\b\b"; echo $PATH | awk 'BEGIN {RS=":"} {print $0}'; _waiter;;
    8) echo "\b\b"; mount | awk '$1 != "none" {print $0}'; _waiter;;
    9) echo "\b\b"; df; _waiter ;;
    0) clear; exit 0 ;;  # breaks the loop
    *) echo " Invalid option...." ; _waiter ;;
} # EOF  _yourc()

while :
  _choices          # display the menu
  _action _yourc    # gather user response

Test Your Knowledge in Computers #229
Difficulty: Easy
According to NetMarketShare, in September 2019 Linux had a 2% global market share of the desktop / laptop computer market.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Command to select files with different extensions

I want to select files which have different extensions such as .cpp, .cs, .h I can select one of them as find . -name "*.cpp" but I want to select all of them in one command only. It should be pretty simple but I'm not able to get it. Any help with the command will be greatly appreciated. (1 Reply)
Discussion started by: MobileUser
1 Replies

2. UNIX for Dummies Questions & Answers

to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's

Hi All, Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'. I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
Discussion started by: manas6
0 Replies

3. Shell Programming and Scripting

Select command array

Hello everyone, I have a quick question about the select command in ksh. I am using it to define a menu for user selection, I have found that the REPLY var contains the input from the user, I was interested to find out if there is a system variable that contains the whole menu as an array, the... (2 Replies)
Discussion started by: gio001
2 Replies

4. Shell Programming and Scripting

Select command to build menu

Hello everyone. I am using the select command to build a menu, here is my question: Is it possible to generate a menu which contains several sections and have a separator between the sections without having a selection number generated in front of the separator? This is a sample of what I would... (1 Reply)
Discussion started by: gio001
1 Replies

5. Shell Programming and Scripting

::select statement return value with correct field size::

Hi Everyone, I am facing a problem regarding the select from sybase, the return with the incorrect size. For example, field is NAME(20). After i selected from sybase, the result is nicky. after i assign it to another declaration variable, it will be in actual name "nicky" , what i need... (10 Replies)
Discussion started by: ryanW
10 Replies

6. Shell Programming and Scripting

Error using select menu command

Hi All, I am trying to use the select command & the menu. below mention is my script #!/bin/bash 2 3 PS3="Is today your birthday? " #PS3 system variable 4 5 echo "\n" 6 7 8 select menu_selection in YES NO QUIT 9 do 10 11 ... (1 Reply)
Discussion started by: milindb
1 Replies

7. Shell Programming and Scripting

How to use select into command in shell script?

I need to get total number of rows in a table by using select count(*) from table and need to assign into a variable in shell script. I used the following script, it does return the number of rows but also with oracle headers, Please help me to eliminate this headers. Shell Script #!/bin/sh... (16 Replies)
Discussion started by: vel4ever
16 Replies

8. Shell Programming and Scripting

Select command help with blank input value

I have a select menu driven script using a case statment and cannot control what happens after a user's input is just <ENTER> or the <SPACEBAR>+<ENTER>. I want it to just hit the "MAIN" function and not redraw the options. I've look everywhere for the answer and am at a loss. Here's the code:... (4 Replies)
Discussion started by: ambroze
4 Replies

9. Shell Programming and Scripting

SQLPLUS command with more than 1 select statement

Hi all, I'm using below code processId=`sqlplus -s ${sysuser}/${syspwd} <<CHK_PROCESS whenever sqlerror exit sql.sqlcode; set head off feedback off echo off pages 0 SELECT PROCESS_ID FROM LSHADMIN.DATA_DOMAIN WHERE DOMAIN_NAME = '${tabname}' ... (8 Replies)
Discussion started by: Pratiksha Mehra
8 Replies

10. UNIX for Beginners Questions & Answers

Select command

Hi I'm using the "select" command in the to log in to the application directory. This file is called in .bashrc profile. Sample code: Filename: set -o vi export severname=$(uname -n) printf '%s\n%30s\n%s\n' "***********************" "Welcome to $severname"... (6 Replies)
Discussion started by: cheers799
6 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.11 3 Aug 1994 echo(1B)

Featured Tech Videos

All times are GMT -4. The time now is 01:34 AM.
Unix & Linux Forums Content Copyright 1993-2021. All Rights Reserved.
Privacy Policy