Sponsored Content
Full Discussion: Select command
Top Forums UNIX for Beginners Questions & Answers Select command Post 303006717 by cheers799 on Tuesday 7th of November 2017 02:23:18 AM
Old 11-07-2017
Select command

Hi
I'm using the "select" command in the global_env.sh to log in to the application directory. This file is called in .bashrc profile.

Sample code:
Filename: global_env.sh


Code:
set -o vi

export severname=$(uname -n)
printf '%s\n%30s\n%s\n' "***********************" "Welcome to $severname" "***********************"

export PS1='$USER:$PWD==>

select env in $(ls -ltrh /app/dwh/|grep ^d|awk '{print $9}') Exit
do
   case "$env" in
        Exit)
             exit
             ;;
        *)
           echo $env
           cd \/app/dwh\/$env
           break
           ;;
   esac
done

Output:
Code:
1. Dir1
2. Dir2
3. Dir3
4. Dir4
5. Exit

This works fine. The moment I enter my credentials, the above options are displayed and successfully able to login to the selected directory.

When I reference the file /app/env/global_env.sh in a shell script, it prompts me to select the application directory. I tried like below but still not working.
When referenced the global_env.sh in a shell script it should not prompt the user to input the option.

Appreciate any suggestions on this.

ScriptName: /var/dwh/Dir1/Test.sh
Code:
#!/bin/bash
export $env=Dir1
. /usr/env/global_env.sh

rm -f /app/dwh/Dir1/*.log

exit 0;

Moderator's Comments:
Mod Comment Please use CODE tags when displaying sample input, output, and code segments (as required by forum rules).

Last edited by Don Cragun; 11-07-2017 at 03:43 AM.. Reason: Add CODE and ICODE tags.
 

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

How to select a particular media from the printer with a UNIX command

Problem Overview: We have a scheduler that prints report on any of the network printer. Problem Statement: We need to find a UNIX command that picks up either A4, legal or letter size paper form the printer. I found out a command but it's not working on our environment. ... (3 Replies)
Discussion started by: HelpMeOUt
3 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

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

6. Solaris

How to select last 7 days entry from SULOG or LAST command

Hi All, I need to get last 7 days log entries from sulog. The same has to be done for the last command. for ex: when i search for a user "abc" in sulog, i only want to check his entries for the last 1 week. The same has to be done for last command. Can anyone suggest some tips. ... (0 Replies)
Discussion started by: navdeepan
0 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. UNIX for Dummies Questions & Answers

Select Command - return

Hello everyone, A simple question which may have a suggested solution: I am using, and loving, the select command in a ksh93 script on AIX 6.1 to present users with menus. I have been successful in controlling all of key input by the users, I still have an issue with the RETURN key. When the... (4 Replies)
Discussion started by: gio001
4 Replies

9. 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

10. 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
All times are GMT -4. The time now is 10:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy