Problem with menu


 
Thread Tools Search this Thread
Operating Systems Linux Problem with menu
# 1  
Old 11-30-2014
Problem with menu

Everything in the following script works fine, except the jobs command. It works when the script is not running, but does not work in the script itself and I cannot figure out why. Any help would be greatly appreciated.

using bash shell
Code:
clear
while
echo " A: Jobs"
echo " B: PS"
echo " C: Kill Process"
echo " Q: Quit"

echo "Please select an option and press <Enter>"
read option
do
case "$option" in

A|a)    jobs -l
        ;;
B|b)    ps -l
        ;;
C|c)    echo "Please enter process number to kill"
read process
kill -9 "$process"
        ;;
Q|q)    exit 0
        ;;
*)      echo "Not a valid option"
        ;;
esac
echo "Press Enter to continue..."
read -p "$*"
more
clear
done

Thank you in advance
# 2  
Old 12-01-2014
Quote:
jobs - display status of jobs in the current session
Source: https://www.unix.com/man-page/linux/1/jobs/

By invoking a shell script, you're basically starting a new session, thus you cannot see the jobs from the previous session.

Actually, your code is working. I added a sleep command on top of your script for a test (sleep command is executed in the background), and it worked:

Code:
sleep 60 & >/dev/null 2>&1
clear
...
...

...
Code:
$ bash menu.sh

...
Code:
 A: Jobs
 B: PS
 C: Kill Process
 Q: Quit
Please select an option and press <Enter>
a
[1]+  7787 Running                 sleep 60 &
Press Enter to continue...

Hope this helps.
# 3  
Old 12-01-2014
That worked to show my jobs, however the inode number seemed to be different then when I ran the jobs -l command outside of the script, and It would not Kill it when I entered the inode with option C of the script.
What ended up working was a space . space before I ran the filename. For example, my filename is script5_sysmenu :

Code:
 . script5_sysmenu

opposed to just

Code:
script5_sysmenu

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Gnome 3.28.3 menu item dissapears under the system menu

I installed CentOS 8 with Gnome 3.28.2 and I noticed that the "switch user" menu item disappeared from under the system menu of Gnome classic (Both X11 & Wayland). I checked google and this problem seems to have a history going back several releases of Gnome. Unfortunately, I never found a... (1 Reply)
Discussion started by: bodisha
1 Replies

2. Shell Programming and Scripting

Need help in create menu with 3 sub menu using the case command

hi all i am a newbie to this is there any examples on creating a main menu with 3 sub menu main menu -> option a , b and c a menu -> option 1 ,2 and 3 b menu -> option 1 ,2 c menu -> option 1 ,2 i am getting headache as my code kept getting unexpected EOF ---------- Post... (0 Replies)
Discussion started by: chercm
0 Replies

3. Shell Programming and Scripting

Execution Problem with dispalying file content using menu driven script

HI All.. below is my menu options script. in option 2,3 and 4 im giving input and they are saving into their respective text file. problem is when im trying to "cat" those files in options 7,8 and 9 im not getting the output. no respective file contents are displaying on screen. but if i... (1 Reply)
Discussion started by: saichand1985
1 Replies

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

5. UNIX for Dummies Questions & Answers

Menu Script problem

Im new to unix/linux and am having trouble with this one. My problem is when i enter 9 to exit it doesnt do so. also option 6 doesent display the time. Its getting to be frustrating. I know there are probably alot of bug in this bu these basic ones are really odd. #!bin/bash # until ... (3 Replies)
Discussion started by: christ.666
3 Replies

6. UNIX for Dummies Questions & Answers

Scripting menu problem

Hi there, I am new to Unix and at the moment I am trying to solve my assignment that is to create a script for the program to prompt user to type three codes, from user point of view it should be done by typing codes separating them by spaces. Then program displays a menu with these three... (5 Replies)
Discussion started by: Dannel
5 Replies

7. Shell Programming and Scripting

Script menu problem

Hi there, I am new to Unix and at the moment I am trying to solve my assignment that is to create a script for the program to prompt user to type three codes, from user point of view it should be done by typing codes separating them by spaces. Then program displays a menu with these three... (2 Replies)
Discussion started by: Dannel
2 Replies

8. Shell Programming and Scripting

Ive got a problem with menu sub commands

Ive got a problem fron a menu script where: If i choose option 1 it will run a command for instance option 1 will run another script that will grep for a certain process name also using the If command. IE if chicken process is present echo cluck cluck, but if no chicken then echo no eggs... (4 Replies)
Discussion started by: wmccull
4 Replies

9. Ubuntu

Start Menu Problem

I posted this at another forum 25 minutes ago and it has only been looked at once. I have much more faith in this forum, as I've had some good help in the shell scripting forum. So I'll just repost this here. I don't know if this is an (K)Ubuntu specific problem, but that is what I use. Problem... (0 Replies)
Discussion started by: notsomeone
0 Replies

10. Shell Programming and Scripting

Scripting problem - when the file is not found i want it to return to the menu

when the file is not found i want it to return to the menu, however it carries out the next line when i hit a key I know its probably something simple can anyone help? here is my pause function: function pause(){ read -s -n 1 -p "Press any key to return to Menu . . ." echo } SCRIPT... (2 Replies)
Discussion started by: Alendrin
2 Replies
Login or Register to Ask a Question