Find the answer to your Linux question:
Results 1 to 9 of 9
Hi All I'm trying to make a very simple menu in bash for launching apps, and to allow me to view log files. The idea is so I won't have ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User stokes's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    274

    Simple bash script


    Hi All

    I'm trying to make a very simple menu in bash for launching apps, and to allow me to view log files. The idea is so I won't have to remember the locations of all the logs, I can just load the script and then just pick them from the menu. This is what I got so far, but the 'viewlogs' option does nothing. Any ideas why the 'more' command wouldn't do anything here?

    Code:
    #! /bin/sh
    
    viewlog() {
    /bin/more /home/vpopmail/qtrap/logs/qtrap.log
    pause
    f_menu
    }
    
    queuel() {
    queue -l
    }
    
    spamconfig() {
    pico /etc/mail/spamassassin/local.cf
    }
    
    f_menu() {
    tput clear
    
    cat << EOF
    
    QMail Admin Menu
    
     1&#41; View QTrap Log
     2&#41; View QMail Queue
     3&#41; Edit SpamAssassin config
     Q&#41; Quit
    
    EOF
    
    echo -n "Prompt> "
    
    read _my_choice
    
    case "$_my_choice" in
     1&#41; viewlog ;;
     2&#41; queuel ;;
     3&#41; spamconfig ;;
     Q|q&#41; exit ;;
    esac
    &#125;
    
    f_menu
    I will add a lot more to this once I've mastered the basic syntax.
    Registered Linux user #389109
    My Semi-Linux Blog

  2. #2
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    Looking at the script and trying it myself, the only thing that I could do to replicate your problem was to have the wrong path for the logfile. So check this. Also you might want to use less rather than more, since less let's you scroll up and down the output, while more only let's you scroll down.
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  3. #3
    Linux Engineer
    Join Date
    Jan 2005
    Location
    Chicago (USA)
    Posts
    1,028
    Two suggestions:
    1. Use less instead of more. You can scroll back up in less.
    2. Use nano instead of pico. Nano's a clone of pico under the GPL.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User stokes's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    274
    Cheers for the tip on using 'less' instead of more.

    dylunio: you were on the right lines, the file exists but is completely empty which is why nothing displays.

    a thing: where do I get nano? I would really prefer to use vi, but it just behaves too strangly on slackware.
    Registered Linux user #389109
    My Semi-Linux Blog

  6. #5
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    If you want nano check out it's site http://www.nano-editor.org/, as for vi behaving strangely in Slack, you might have been used to VIM (Vi IMproved), not vi, ofter vi is symlinked to vim on systems that use vim instead of vi. To grab VIM, go to http://www.vim.org/.
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  7. #6
    Linux Engineer
    Join Date
    Mar 2005
    Posts
    1,431
    Quote Originally Posted by stokes
    Cheers for the tip on using 'less' instead of more.

    dylunio: you were on the right lines, the file exists but is completely empty which is why nothing displays.

    a thing: where do I get nano? I would really prefer to use vi, but it just behaves too strangly on slackware.
    Check the file /etc/vim/vimrc (or ~user/.vimrc). I belive you can make vim behave "classic vi" or in the new mode like this (token from my /etc/vim/vimrc):
    Code:
    set nocompatible
    Try adding that...

    About nano, look here:
    http://www.nano-editor.org/download.html

  8. #7
    Linux User stokes's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    274
    Quote Originally Posted by dylunio
    If you want nano check out it's site http://www.nano-editor.org/, as for vi behaving strangely in Slack, you might have been used to VIM (Vi IMproved), not vi, ofter vi is symlinked to vim on systems that use vim instead of vi. To grab VIM, go to http://www.vim.org/.
    Cool! That's back to the way I'm used to. Nice one!
    Registered Linux user #389109
    My Semi-Linux Blog

  9. #8
    Linux Guru dylunio's Avatar
    Join Date
    Aug 2004
    Location
    Cymru
    Posts
    4,157
    Quote Originally Posted by stokes
    Cool! That's back to the way I'm used to. Nice one!
    Glad you sorted it
    Registered Linux User #371543!
    Get force-get May The Source Be With You
    /dev/null
    /dev/null2

  10. #9
    Linux Engineer
    Join Date
    Mar 2005
    Posts
    1,431
    I thought slack used vim by default? (symlinked vi as you said)

Posting Permissions

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