Sponsored Content
Full Discussion: Submenu variable problems
Top Forums Shell Programming and Scripting Submenu variable problems Post 302529236 by skizo787 on Wednesday 8th of June 2011 10:21:30 PM
Old 06-08-2011
Submenu variable problems

Quote:
enter_cont () {

echo "Press Enter to continue"
read ans
}

top_proc () {

tput clear
ps aux | grep -v kproc | head -15
echo "Press Enter to continue"
read ans
}

dup_check () {

clear
cmp $outputfile $pwd
echo "Press Enter to continue"
read ans
}

check_exe () {

clear
find $HOME -type f -perm -g+rx
echo "Press Enter to continue"
read ans
}

date_check () {

clear
echo "The date is"
echo "`date`"
echo "$outputfile"
echo "$outputfile2"
echo "Press Enter to continue"
read ans
}

file_dir () {

clear
if [ -f $outputfile ];
then
echo "File [$outputfile] exists"
else
echo "File [$outputfile] does not exists"
fi
if [ -d $outputfile2 ];
then
echo "Directory [$outputfile2] exits"
else
echo "Directory [$outputfile2] does not exist"
fi
if [ -f $outputfile ] && [ -d $outputfile2 ];
then
cp $outputfile $outputfile2
echo "[$outputfile] file has been copied to directory [$outputfile2]"
fi
echo "Press Enter to continue"
read ans
}

search_proc () {

outputfile3=$3
clear
echo 'Type Proccess name to search for then press ENTER '
ps -ewwo pid,args | grep $outputfile3 | awk '{print $1}'
}

outputfile=$1
outputfile2=$2
if [ $# -eq 0 ]
then
echo "You must enter a filename"
exit
fi
until [ -n "$validchoice" ]
do
tput clear

echo " ~~~~~~~~~~~~~~~~~~~~~"
echo " M A I N - M E N U"
echo " ~~~~~~~~~~~~~~~~~~~~~"
echo " 1) Show top 15 processes (CPU)"
echo " 2) Check for duplicates"
echo " 3) Check for executables in current dir"
echo " 4) Date"
echo " 5) Check file and directory"
echo " 6) Search Processes"
echo " x) Logout"

read choice;echo

case $choice in
1) top_proc;;
2) dup_check;;
3) check_exe;;
4) date_check;;
5) file_dir;;
6) search_proc;;
x) validchoice=TRUE;;
*) echo "Invalid option";enter_cont;;
esac
done
The problem is

Quote:
search_proc () {

outputfile3=$3
clear
echo 'Type Proccess name to search for then press ENTER '
ps -ewwo pid,args | grep $outputfile3 | awk '{print $1, $2}'
}
I need it too go from the main menu by pressing 6, to the submenu search_proc. In the search_proc menu/section it need to accept a variable and search the processes for it and sort by PID and Process name. I'm stuck and ran out of ideas. I also cannot figure out why it keeps flashing quick and going back to the main menu.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

variable= 'cat file|wc -l' String problems

Hi, does anybody knows about wc -l, how to transform it inot a just number? this script ALWAYS executes the command3!!, However, the value of BMU_RUNNING is 1 case $BMU_RUNNING in *0) command1 ;; *1) command 2;; *)command 3;; esac The... (3 Replies)
Discussion started by: Santiago
3 Replies

2. Shell Programming and Scripting

Problems reiterating values from txt file into a variable

Hi, I have written a script to retrieve phone numbers from an error log and output the phone numbers into an text file. I then use the list of phone numbers to process each value into a variable so I can run a sql query and update the database. My problem is I can only process the first value... (2 Replies)
Discussion started by: rdr411
2 Replies

3. Shell Programming and Scripting

SubMenu Exit problem!

I basically have a menu driven script in which one of the options from the main menu would open a sub menu, this works fine but i can't seem to be able to exit the sub menu back to the main menu....any ideas? (5 Replies)
Discussion started by: Alendrin
5 Replies

4. Shell Programming and Scripting

Problems with variable

Hey all. I have trouble passing a variable from inside a loop. # find all output.txt that has been modified last 24h ... PROCESSED=1 find ${PROCESSED_DIR} -mtime -1 -name "output.txt" | while read i do # .. and compare those with TMP_TXT if diff $i... (3 Replies)
Discussion started by: rrahmegni
3 Replies

5. Shell Programming and Scripting

How to define a variable with variable definition is stored in a variable?

Hi all, I have a variable say var1 (output from somewhere, which I can't change)which store something like this: echo $var1 name=fred age=25 address="123 abc" password=pass1234 how can I make the variable $name, $age, $address and $password contain the info? I mean do this in a... (1 Reply)
Discussion started by: freddy1228
1 Replies

6. Shell Programming and Scripting

Return to a submenu

Hi, I have this menu: main_menu() { while true do print " ************************************" clear print " 1) Configuracion de RBAC (ADMIN)." print " 2) Configuracion de roles a usuarios (SISTEMAS)." print " 3) Salir." ... (6 Replies)
Discussion started by: iga3725
6 Replies

7. Shell Programming and Scripting

Problems assigning a string to a variable

Hello everyone, My problem looks quite simple , how to assign a string with spaces and lines "\n" to a variable. I've tried all kind of quoting and is impossible, bash always try to execute the string and never executes a simple assignation. This is part of the code ... (1 Reply)
Discussion started by: trutoman
1 Replies

8. Shell Programming and Scripting

Execution Problems with the value is not store in a variable

#!/bin/bash filecount=0 dirname=path.log exec<$dirname while read line # line by line read source file name and stored in a veribale do sourcedirname=$line ( count=`ls $sourcedirname |wc -l` filecount=`expr $filecount + $count` echo $filecount ... (2 Replies)
Discussion started by: mnmonu
2 Replies

9. Shell Programming and Scripting

Problems setting or exporting variable when using multiple commands from same line.

I am experimenting with some scripting as a way to learn more about it. I have a simple script that calls two other scripts. Each script echos some stuff to prove it ran and then sets a simple variable and exports it. I cannot get one of the variables to display back in the main calling script... (2 Replies)
Discussion started by: scottrif
2 Replies

10. Shell Programming and Scripting

Bash script having variable substitution problems

Hi I am setting the variables like this : setenv MODULE1 modem5__3 setenv MODULE2 modem5__2 setenv MODULE3 modem_ctrl_1_1 setenv MODULE4 modem_1_0 setenv COUNT 10 I am having a bash script as shown below ################################################ #!/bin/bash for ((... (5 Replies)
Discussion started by: kshitij
5 Replies
clear(1)						      General Commands Manual							  clear(1)

NAME
clear - clear the terminal screen SYNOPSIS
clear [-Ttype] [-V] [-x] DESCRIPTION
clear clears your screen if this is possible, including its scrollback buffer (if the extended "E3" capability is defined). clear looks in the environment for the terminal type given by the environment variable TERM, and then in the terminfo database to determine how to clear the screen. clear writes to the standard output. You can redirect the standard output to a file (which prevents clear from actually clearing the screen), and later cat the file to the screen, clearing it at that point. OPTIONS
-T type indicates the type of terminal. Normally this option is unnecessary, because the default is taken from the environment variable TERM. If -T is specified, then the shell variables LINES and COLUMNS will also be ignored. -V reports the version of ncurses which was used in this program, and exits. The options are as follows: -x do not attempt to clear the terminal's scrollback buffer using the extended "E3" capability. HISTORY
A clear command appeared in 2.79BSD dated February 24, 1979. Later that was provided in Unix 8th edition (1985). AT&T adapted a different BSD program (tset) to make a new command (tput), and used this to replace the clear command with a shell script which calls tput clear, e.g., /usr/bin/tput ${1:+-T$1} clear 2> /dev/null exit In 1989, when Keith Bostic revised the BSD tput command to make it similar to the AT&T tput, he added a shell script for the clear command: exec tput clear The remainder of the script in each case is a copyright notice. The ncurses clear command began in 1995 by adapting the original BSD clear command (with terminfo, of course). The E3 extension came later: o In June 1999, xterm provided an extension to the standard control sequence for clearing the screen. Rather than clearing just the vis- ible part of the screen using printf '33[2J' one could clear the scrollback using printf '33[3J' This is documented in XTerm Control Sequences as a feature originating with xterm. o A few other terminal developers adopted the feature, e.g., PuTTY in 2006. o In April 2011, a Red Hat developer submitted a patch to the Linux kernel, modifying its console driver to do the same thing. The Linux change, part of the 3.0 release, did not mention xterm, although it was cited in the Red Hat bug report (#683733) which led to the change. o Again, a few other terminal developers adopted the feature. But the next relevant step was a change to the clear program in 2013 to incorporate this extension. o In 2013, the E3 extension was overlooked in tput with the "clear" parameter. That was addressed in 2016 by reorganizing tput to share its logic with clear and tset. PORTABILITY
Neither IEEE Std 1003.1/The Open Group Base Specifications Issue 7 (POSIX.1-2008) nor X/Open Curses Issue 7 documents tset or reset. The latter documents tput, which could be used to replace this utility either via a shell script or by an alias (such as a symbolic link) to run tput as clear. SEE ALSO
tput(1), terminfo(5) This describes ncurses version 6.1 (patch 20180127). clear(1)
All times are GMT -4. The time now is 06:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy