Find the answer to your Linux question:
Results 1 to 5 of 5
search_proc () { outputfile3=$3 clear echo 'Type Proccess name to search for then press ENTER ' ps -ewwo pid,args | grep $outputfile3 | awk '{print $1}' } I have created ...
  1. #1
    Just Joined!
    Join Date
    Jun 2011
    Posts
    4

    Variables within a sub menu problems

    search_proc () {

    outputfile3=$3
    clear
    echo 'Type Proccess name to search for then press ENTER '
    ps -ewwo pid,args | grep $outputfile3 | awk '{print $1}'
    }
    I have created a menu and this submenu. What i bascially need to do is have it accept a variable once it goes too this menu and do this. Any help is appreciated.

    ps -ewwo pid,args | grep $outputfile3 | awk '{print $1}'

  2. #2
    Just Joined!
    Join Date
    Jun 2011
    Posts
    4
    I am still a newby and learning. The menu does not stay at that screen either, not sure what i did wrong. Thanks in advance.

  3. #3
    Linux Guru
    Join Date
    May 2011
    Posts
    1,843
    It is not clear to me what you are trying to do. Are you trying to get input from the user, save it to a variable, and then run your ps|grep|awk command against that? If so, check out the read shell builtin command provided with bash. If you mean something else, please elaborate.

  4. #4
    Just Joined!
    Join Date
    Jun 2011
    Posts
    4
    Yes that is what i'm trying to do. What are you saying i need to read?

  5. #5
    Linux Guru
    Join Date
    May 2011
    Posts
    1,843
    literally, you use the read command in your shell script to get the user input stored as a variable, e.g.:
    Code:
    read -p "Tell me something funny " joke
    echo You said $joke
    for more, man bash and look for the 'read' entry under the section SHELL BUILTIN COMMANDS.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...