Sponsored Content
Top Forums Shell Programming and Scripting Shell script menu for end user - difficult challenge Post 302565697 by waso on Tuesday 18th of October 2011 01:36:41 PM
Old 10-18-2011
CPU & Memory Shell script menu for end user - difficult challenge

Hello,

I need to make shell script menu for my end users. There is like 100 scripts in system, and they need to run that scripts true one main script with user friendly menu.

Example, when user will run main menu script, it will get something like this on his screen:
_________________________________________________________

Please insert number of steps?
User: 3

Insert step 1?
User: script47.sh
Insert check return code for script1.sh?
0

Insert step 2?
User: script78.sh
Insert check return code for script78.sh?
1

Insert step 3?
User: script34.sh
Insert check return code for script34.sh?
0
_________________________
Check before running the scripts:
1. Step: script1.sh -- return code 0
2. Step: script78.sh -- return code 1
3. Step: script34.sh -- return code 0
For continue insert yes
User: yes
**************************
Then script executing look like this
/app/test/script47.sh
chk_rc_100
/app/test/script78.sh
chk_rc_100
/app/test/script34.sh
chk_rc_100
_________________________________________________________

This is example of main script if you make it with fixed parameter, this is like some plan of executing, but i need to make menu so user can pick how many script will run and enter scripts name. Check return code is same for every case.

Code:
#Check for RC=100 
chk_rc_100() {
        ret_code=$?
        if [ "$ret_code" != "100" ]
                then
                        echo "!!!!!"
                        echo "Script finished with error!"
                        echo "!!!!!"
                        exit $ret_code
                fi
                fi
}


CMD="/app/test/script47.sh"
$CMD
chk_rc_100

CMD="/app/test/script27.sh"
$CMD
chk_rc_100

CMD="/app/test/script31.sh"
$CMD
chk_rc_100

CMD="/app/test/script79.sh"
$CMD
chk_rc_100


Last edited by waso; 10-19-2011 at 04:44 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unix Shell Script: With Menu Option

I am attempting to create a shell script with the following capaciblities: 1. Listed options to choice from 2. Use to perform awk statements 3. Print a report with the awk results My questions are 1. How do I select more than one file for option #5 and #6 2. How to I create an... (11 Replies)
Discussion started by: jroberson
11 Replies

2. Shell Programming and Scripting

need shell script for this challenge problem

two tabulate files (A, B), each contents thousands and thousands lines with ids. first find out contents with common ids in both A, B and print out into a file; second find out contents with ids which only exist in file A and print out into a file. (4 Replies)
Discussion started by: ssshen
4 Replies

3. Shell Programming and Scripting

Shell script menu

hi guys, how would you do the following? I have a menu with 5 options in my shell script: 1. Run function 1 against files 2. Run function 2 against files 3. Run function 3 against files 4. Run function 4 against files 5. Run function 5 against files I'd like to be able to run multiple... (10 Replies)
Discussion started by: rich@ardz
10 Replies

4. Shell Programming and Scripting

Menu using shell script

Hi, I need to have a shell script for the below need. 1. Menu with one heading and 4 options. 2. the heading and 4 options are taken from a file. File entry ====== Heading1|option1|option2|option3|option4| Heading2|option1|option2|option3|option4| 3. the user entries must be captured in... (9 Replies)
Discussion started by: umastinu
9 Replies

5. Shell Programming and Scripting

Shell script menu problem

I have tried searching the forum but i haven't found a solution for this. I have a shell script that presents the users with menus. The menus branch out to sub menus. It is all hunky dory as long as i traverse forward. But if i am in a sub menu and return to the previous menu and choose any... (11 Replies)
Discussion started by: goddevil
11 Replies

6. Shell Programming and Scripting

Shell script menu for end user - difficult challenge 2

Hello, I need to make shell script menu for my end users. There is like 100 scripts in system, and they need to run that scripts true one main script with user friendly menu. Example, when user will run main menu script, it will get something like this on his screen:... (1 Reply)
Discussion started by: waso
1 Replies

7. Shell Programming and Scripting

A selection menu in a shell script

I'm writing a shell script and have a problem with selection when I issue the command, is there a way to automatically choose a selection number one after a selection menue appear Command 1-choice 2- choice 3-choice Thanks Sara (3 Replies)
Discussion started by: Sara_84
3 Replies

8. Shell Programming and Scripting

Menu shell script help

Hi All, I have written a shell script that show menu driven option. My requirement is that in the menu driven option i want to select multiple choice. i.e if i want to select 1 or 1,2 or 1,2,3 or 2,3 etc .... Can some one help me in that My script. while true; do echo " " ... (8 Replies)
Discussion started by: Nawrajesh
8 Replies

9. Shell Programming and Scripting

Automate the menu options using shell script

I have a menu option which will look as follows Select a menu option 1.change password 2.login as root user 3.show system version 4.quit Select> 1 please enter the new password: unix reenter the new password: unix press any key to enter (then displays again the menu options to enter the... (4 Replies)
Discussion started by: shivakumar6g
4 Replies
CGI::Emulate::PSGI(3pm) 				User Contributed Perl Documentation				   CGI::Emulate::PSGI(3pm)

NAME
CGI::Emulate::PSGI - PSGI adapter for CGI SYNOPSIS
my $app = CGI::Emulate::PSGI->handler(sub { # Existing CGI code }); DESCRIPTION
This module allows an application designed for the CGI environment to run in a PSGI environment, and thus on any of the backends that PSGI supports. It works by translating the environment provided by the PSGI specification to one expected by the CGI specification. Likewise, it captures output as it would be prepared for the CGI standard, and translates it to the format expected for the PSGI standard using CGI::Parse::PSGI module. CGI.pm If your application uses CGI, be sure to cleanup the global variables in the handler loop yourself, so: my $app = CGI::Emulate::PSGI->handler(sub { use CGI; CGI::initialize_globals(); my $q = CGI->new; # ... }); Otherwise previous request variables will be reused in the new requests. Alternatively, you can install and use CGI::Compile from CPAN and compiles your existing CGI scripts into a sub that is perfectly ready to be converted to PSGI application using this module. my $sub = CGI::Compile->compile("/path/to/script.cgi"); my $app = CGI::Emulate::PSGI->handler($sub); This will take care of assigning an unique namespace for each script etc. See CGI::Compile for details. You can also consider using CGI::PSGI but that would require you to slightly change your code from: my $q = CGI->new; # ... print $q->header, $output; into: use CGI::PSGI; my $app = sub { my $env = shift; my $q = CGI::PSGI->new($env); # ... return [ $q->psgi_header, [ $output ] ]; }; See CGI::PSGI for details. METHODS
handler my $app = CGI::Emulate::PSGI->handler($code); Creates a PSGI application code reference out of CGI code reference. emulate_environment my %env = CGI::Emulate::PSGI->emulate_environment($env); Creates an environment hash out of PSGI environment hash. If your code or framework just needs an environment variable emulation, use this method like: local %ENV = (%ENV, CGI::Emulate::PSGI->emulate_environment($env)); # run your application If you use "handler" method to create a PSGI environment hash, this is automatically called in the created application. AUTHOR
Tokuhiro Matsuno <tokuhirom@cpan.org> Tatsuhiko Miyagawa COPYRIGHT AND LICENSE
Copyright (c) 2009-2010 by tokuhirom. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. SEE ALSO
PSGI CGI::Compile CGI::PSGI Plack CGI::Parse::PSGI perl v5.14.2 2012-03-18 CGI::Emulate::PSGI(3pm)
All times are GMT -4. The time now is 03:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy