Interactive UNIX shell query


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Interactive UNIX shell query
# 1  
Old 06-17-2012
Interactive UNIX shell query

Hi guys,

I've create 3 shells concerning my work, which named as 1.sh, 2.sh and 3.sh.
However, how can I make an interactive query for these shells just like the old (fdisk) in windows9x. I want to make an interface tells the user just like this:

Code:
Press 1 to execute "1.sh"
Press 2 to execute 2.sh. 
Press 3 to execute 3.sh

Press any key to exit.

Looking for your valued solutions guys...

Leo
# 2  
Old 06-18-2012
Java

zenity or kdialogs are the best solution to get GUI in a shell script.

May be if you are looking a solution in command line then this should do the needful.

Code:
#!/bin/bash
echo "Press 1 to execute 1.sh
Press 2 to execute 2.sh. 
Press 3 to execute 3.sh

Press any key to exit." ;

read input
case $input in
1) echo "Executing script 1.sh"; ./1.sh ;;
2) echo "Executing script 2.sh"; ./2.sh ;;
3) echo "Executing script 3.sh"; ./3.sh ;;
*) echo "Invalid entry"; exit;;
esac

This User Gave Thanks to Arun_Linux For This Post:
# 3  
Old 06-18-2012
Is this working under HP-UX?
# 4  
Old 06-18-2012
sorry i dont have HP-UX machine.. Btw its working in solaris and linux suse.
I guess the script is simple and no *nix flavor dependencies . May be you have to edit the first line i.e. cross check your shell path. Mine was :

Code:
solaris3_arun:> which bash
/bin/bash

# 5  
Old 06-18-2012
To run in the default Posix shell on HP-UX, just delete the Shebang line (the one mentioning bash).
# 6  
Old 06-18-2012
If your shell supports it, read up on the "select" construct for creating a menu:

Code:
man select

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unix shell script to query linux top consuming processes

Hi All, O/S: Linux 86x64 Red Hat I have a sql script that queries top consuming processes of Linux using TOP commnd. Now I need to automate this task and pass the top processes i.e., PID to the sql script through unix shell script. Could anyone please let me know how to achieve this. ... (2 Replies)
Discussion started by: a1_win
2 Replies

2. Shell Programming and Scripting

Isql query in unix shell

Hi i want write a script for list of sysbase are having access or open. then i wrote like: USER="abc" PASS="xyz" SERVER="SCCS" DB="blue" WORK_DIR="/usr/home/ramakrishna" set -x isql -U${USER} -P${PASS} -S${SERVER}<<EOF>$WORK_DIR/output.log go use blue (database name) go use... (0 Replies)
Discussion started by: koti_rama
0 Replies

3. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

4. UNIX for Dummies Questions & Answers

executing SQL query using unix shell script

I want to perform few post-session success tasks like update a status to 'true' in one of the sql database table, update date values to current system date in one of the configuration table in sql. How do i achieve this in a post session command?syntax with example will be helpful. (3 Replies)
Discussion started by: nathanvaithi
3 Replies

5. Homework & Coursework Questions

Help with Interactive / Non Interactive Shell script

Q. Write a script that behaves both in interactive and non interactive mode. When no arguments are supplied it picks up each C program from the directory and prints first 10 lines. It then prompts for deletion of the file. If user supplies arguments with the script , then it works on those files... (1 Reply)
Discussion started by: rits
1 Replies

6. Shell Programming and Scripting

how to use data in unix text file as input to an sql query from shell

Hi, I have data in my text file something like this. adams robert ahmed gibbs I want to use this data line by line as input to an sql query which i run by connecting to an oracle database from shell. If you have code for similar scenario , please ehlp. I want the output of the sql query... (7 Replies)
Discussion started by: rdhanek
7 Replies

7. Shell Programming and Scripting

A simple query on unix shell script

I want to write a script to go to particular path in file and run shell script from there. what will be shell script for the same. (2 Replies)
Discussion started by: shekhar_ssm
2 Replies

8. Shell Programming and Scripting

isql query in unix shell script

Dear all I want to execute some isql command from unix shell script. Kindly suggest me. isql command mention below. isql -U -P use gdb_1 go select count (*) from table_x go (3 Replies)
Discussion started by: jaydeep_sadaria
3 Replies

9. UNIX for Dummies Questions & Answers

sql query results in unix shell script

Hi I want to get the a field from a SQL query into unix shell script variable. the whole situation is like this. 1. Opened a cursor to a table in DB2 databse. 2. Fetching individual rows with the help of cursor. 3. Each row has 4 fields. I want each of the field in individual shell... (1 Reply)
Discussion started by: skyineyes
1 Replies

10. Shell Programming and Scripting

How to hide user inputted text for interactive unix shell script?

Hi everybody, Do you know how to hide the text for interactive unix shell script? Just like the case for inputting password during logon. Patrick (1 Reply)
Discussion started by: patrickpang
1 Replies
Login or Register to Ask a Question