Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 26

Thread: Impossibilitus Interruptus ...

  1. #11
    Join Date
    Oct 2010
    Location
    Above ground...(for now)
    Beans
    761

    Re: Impossibilitus Interruptus ...

    Quote Originally Posted by Langstracht View Post
    In response to steeldriver - if I did any of those things it was inadvertently. Info as to how "normal service might be resumed" would be very helpful.

    In response to Crusty Old Fart - the sum total of the script was on the page. Sorry I don't see a "code box option".
    See if your script runs if you put the following line in as the very first line of your code (it's called a shebang):
    Code:
    #!/bin/bash
    Here's how to make a code box:
    Code:
    [code]
    This text
    will appear
    in a code
    box
    [/code]
    Suffering from severe chronic female supervision deficiency syndrome resulting in
    an increasing intolerance of adolescent scatological effluence and PMS induced nefarious diatribe.
    How to: Mark your thread as: [SOLVED]

  2. #12
    Join Date
    Aug 2006
    Beans
    344

    Re: Impossibilitus Interruptus ...

    Code:
    #!/bin/bash
    
    set -e
    
    count=10
    
    i=1
    
    while [ $i -le $count ]
    
    do
    
    tail -$i filename.txt
    
    i=`expr $i + 1`
    
    read -p "Hit [Enter] to continue or [Ctrl+C] to abort."
    
    
    done
    The above code displays every line it is supposed to ... plus the "Hit [ ... abort." after each "batch" of lines. It does NOT pause the output.

    Thank you in advance for your much needed and much appreciated help.

  3. #13
    Join Date
    Aug 2006
    Beans
    344

    Re: Impossibilitus Interruptus ...

    Sorry, my last post was incorrect.

    This

    Code:
    #!/bin/bash
    
    set -e
    
    count=10
    
    i=1
    
    while [ $i -le $count ]
    
    do
    
    tail -$i filename.txt
    
    i=`expr $i + 1`
    
    read -p "Hit [Enter] to continue or [Ctrl+C] to abort."
    
    
    done
    is the code that performs in the stated fashion.

    The thanks in advance continues to apply.

  4. #14
    Join Date
    Oct 2010
    Location
    Above ground...(for now)
    Beans
    761

    Re: Impossibilitus Interruptus ...

    Quote Originally Posted by Langstracht View Post
    ...
    The thanks in advance continues to apply.
    You might want to remember that you'll need to use the "shebang" as the first line of every bash script that you write in the future:
    Code:
    #!/bin/bash
    Last edited by Crusty Old Fart; September 7th, 2013 at 09:18 PM. Reason: confusion
    Suffering from severe chronic female supervision deficiency syndrome resulting in
    an increasing intolerance of adolescent scatological effluence and PMS induced nefarious diatribe.
    How to: Mark your thread as: [SOLVED]

  5. #15
    Join Date
    Aug 2006
    Beans
    344

    Re: Impossibilitus Interruptus ...

    The referred to "stated fashion" was the script NOT working. So I am afraid I will not be marking the thread as solved. Cos it ain't!

  6. #16
    Join Date
    Oct 2010
    Location
    Above ground...(for now)
    Beans
    761

    Re: Impossibilitus Interruptus ...

    Quote Originally Posted by Langstracht View Post
    The above code displays every line it is supposed to ... plus the "Hit [ ... abort." after each "batch" of lines. It does NOT pause the output...
    Well, maybe I don't understand what you want the script to do.
    You write: "The above code displays every line it is supposed to ... plus the "Hit [ ... abort." after each "batch" of lines." <-- That's what it's supposed to do. And you should be having to hit the [Enter] key to get the script to display each successive "batch" of lines.

    The contents of the script I am testing are as follows:
    Code:
    #!/bin/bash
    
    set -e
    
    count=10
    
    i=1
    
    while [ $i -le $count ]
    
    do
    
    tail -$i filename.txt
    
    i=`expr $i + 1`
    
    read -p "Hit [Enter] to continue or [Ctrl+C] to abort."
    
    
    done
    To test the script, I created a file named: filename.txt, which contains the following:
    Code:
    This is line 1.
    This is line 2.
    This is line 3.
    This is line 4.
    This is line 5.
    This is line 6.
    This is line 7.
    This is line 8.
    This is line 9.
    This is line 10.
    When I run the script, which I named listpause.sh, I get this:
    Code:
    $ ./listpause.sh
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    The scripts pauses. Then I hit the [Enter] key and I get this "batch" of lines:
    Code:
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    The scripts pauses again. And again, I hit the [Enter] key and I get this "batch" of lines:
    Code:
    This is line 8.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    And so on...until the script finally reaches the end of the loop counter. At that point, the last "batch" of output looks like this:
    Code:
    This is line 1.
    This is line 2.
    This is line 3.
    This is line 4.
    This is line 5.
    This is line 6.
    This is line 7.
    This is line 8.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    ...And the script stops, and I'm returned to my user prompt.
    This is how the script is supposed to work. If this is not how you want it to work, then I have yet to understand what you're asking for.

    If the behavior of the script, as I've explained above, is the way you want it to work, but it isn't working this way for you, then:
    • Please post the output you get, in a code box, when you run it.
    • Also, please post the outputs you get from the following commands in separate code boxes:
    Code:
    echo "IFS = '$IFS'"
    echo "PATH = $PATH'"
    cat ~/.bashrc
    On the other hand, if the behavior of the script, as I've explained above, is NOT the way you want it to work, then please try to explain how you want it to behave.

    Thanks,

    Crusty
    Last edited by Crusty Old Fart; September 7th, 2013 at 11:25 PM.
    Suffering from severe chronic female supervision deficiency syndrome resulting in
    an increasing intolerance of adolescent scatological effluence and PMS induced nefarious diatribe.
    How to: Mark your thread as: [SOLVED]

  7. #17
    Join Date
    Aug 2006
    Beans
    344

    Re: Impossibilitus Interruptus ...

    I want the script to:

    display the last line
    pause

    display the last two lines
    pause

    display the last three lines
    pause

    ...

    and so on until there are no more lines to display

    as you have delineated.

    For me, the script does just that ... except it does NOT pause ... but ploughs on through all the displays of all the lines.

    It seems I have been unable to describe that ... for which I apologize.

    The 3 commands you list result in the following responses:

    ************************************************** ***************

    IFS = '
    '

    ************************************************** ****************

    PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games'

    ************************************************** ****************

    # ~/.bashrc: executed by bash(1) for non-login shells.
    # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
    # for examples

    # If not running interactively, don't do anything
    [ -z "$PS1" ] && return

    # don't put duplicate lines in the history. See bash(1) for more options
    # ... or force ignoredups and ignorespace
    HISTCONTROL=ignoredups:ignorespace

    # append to the history file, don't overwrite it
    shopt -s histappend

    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=1000
    HISTFILESIZE=2000

    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize

    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
    fi

    # set a fancy prompt (non-color, unless we know we "want" color)
    case "$TERM" in
    xterm-color) color_prompt=yes;;
    esac

    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    #force_color_prompt=yes

    if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
    fi

    if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    fi
    unset color_prompt force_color_prompt

    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
    *)
    ;;
    esac

    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
    fi

    # some more ls aliases
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'

    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.

    if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
    fi

    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion
    fi

    ************************************************** *******************

    Thank you for your continued involvement.

  8. #18
    Join Date
    Apr 2012
    Beans
    6,874

    Re: Impossibilitus Interruptus ...

    Are you holding down the 'Enter' key after you execute the command? if so, the keyboard auto-repeat will make it look like you are responding to multiple read prompts

    BTW your posts would be much more readable if you used the [CODE]...[∕CODE] tags around your code

  9. #19
    Join Date
    Oct 2010
    Location
    Above ground...(for now)
    Beans
    761

    Re: Impossibilitus Interruptus ...

    Quote Originally Posted by Langstracht View Post
    ...It seems I have been unable to describe that ... for which I apologize.
    Yeah...well...that's why I told you to:
    • Please post the output you get, in a code box, when you run it.


    So, based on what you described, in lieu of posting the output, I'm assuming that when you run the script: it pukes out ten "batches" of lines, each ending with the "Hit [Enter]..." message, and then serves your user input prompt without you touching the keyboard since you gave the shell the command to run the script. I can simulate that by holding down the [Enter] key until the script finishes. Using my test file I get the following output, in a single dump:
    Code:
    $ ./promptpause.sh
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    This is line 8.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    This is line 7.
    This is line 8.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    This is line 6.
    This is line 7.
    This is line 8.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    This is line 5.
    This is line 6.
    This is line 7.
    This is line 8.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    This is line 4.
    This is line 5.
    This is line 6.
    This is line 7.
    This is line 8.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    This is line 3.
    This is line 4.
    This is line 5.
    This is line 6.
    This is line 7.
    This is line 8.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    This is line 2.
    This is line 3.
    This is line 4.
    This is line 5.
    This is line 6.
    This is line 7.
    This is line 8.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    This is line 1.
    This is line 2.
    This is line 3.
    This is line 4.
    This is line 5.
    This is line 6.
    This is line 7.
    This is line 8.
    This is line 9.
    This is line 10.
    Hit [Enter] to continue or [Ctrl+C] to abort.
    Quote Originally Posted by Langstracht View Post
    ...The 3 commands you list result in the following responses:
    Thanks. I'll put them into code boxes so I can read them more easily and to prevent myself from confusing backticks with single quotes, colons with semicolons, and periods with commas...etc:

    Code:
    $ echo "IFS = '$IFS'"
    IFS = '     
    '
    That one looks okay.

    Next:
    Code:
    $ echo "PATH = $PATH'"
    PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games'
    Ahhh...There's part of the problem--maybe even the whole crux. We'll fix this by editing your ~/.bashrc file a little later in this post.

    The last one:
    Code:
    $ cat ~/.bashrc
    # ~/.bashrc: executed by bash(1) for non-login shells.
    # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
    # for examples
    
    # If not running interactively, don't do anything
    [ -z "$PS1" ] && return
    
    # don't put duplicate lines in the history. See bash(1) for more options
    # ... or force ignoredups and ignorespace
    HISTCONTROL=ignoredups:ignorespace
    
    # append to the history file, don't overwrite it
    shopt -s histappend
    
    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=1000
    HISTFILESIZE=2000
    
    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize
    
    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
    
    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
        debian_chroot=$(cat /etc/debian_chroot)
    fi
    
    # set a fancy prompt (non-color, unless we know we "want" color)
    case "$TERM" in
        xterm-color) color_prompt=yes;;
    esac
    
    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    #force_color_prompt=yes
    
    if [ -n "$force_color_prompt" ]; then
        if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
        else
        color_prompt=
        fi
    fi
    
    if [ "$color_prompt" = yes ]; then
        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    else
        PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    fi
    unset color_prompt force_color_prompt
    
    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
    esac
    
    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
        test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
        alias ls='ls --color=auto'
        #alias dir='dir --color=auto'
        #alias vdir='vdir --color=auto'
    
        alias grep='grep --color=auto'
        alias fgrep='fgrep --color=auto'
        alias egrep='egrep --color=auto'
    fi
    
    # some more ls aliases
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    
    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    
    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
    
    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
        . /etc/bash_completion
    fi
    That looks good.

    Now we'll fix the problem with your PATH environment variable by adding some code to the bottom of your ~/.bashrc file.

    Before we do that, we should make a copy of ~/.bashrc so that we can revert back to it in case we hose the code addition. We'll name the copy of ~/.bashrc as: ~/.bashrc_original. Please execute the following command:
    Code:
    cp -p ~/.bashrc ~/.bashrc_original
    Now we'll add the code we need to the bottom of your ~/.bashrc file. The code box below shows the entire contents of the ~/.bashrc file you should end up with. The code we're adding is shown in bold blue text at the bottom of the file. NOTE: Replace the instances of the bold red text: your_user_name with whatever your user name is.
    Code:
    # ~/.bashrc: executed by bash(1) for non-login shells.
    # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
    # for examples
    
    # If not running interactively, don't do anything
    [ -z "$PS1" ] && return
    
    # don't put duplicate lines in the history. See bash(1) for more options
    # ... or force ignoredups and ignorespace
    HISTCONTROL=ignoredups:ignorespace
    
    # append to the history file, don't overwrite it
    shopt -s histappend
    
    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=1000
    HISTFILESIZE=2000
    
    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize
    
    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
    
    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
        debian_chroot=$(cat /etc/debian_chroot)
    fi
    
    # set a fancy prompt (non-color, unless we know we "want" color)
    case "$TERM" in
        xterm-color) color_prompt=yes;;
    esac
    
    # uncomment for a colored prompt, if the terminal has the capability; turned
    # off by default to not distract the user: the focus in a terminal window
    # should be on the output of commands, not on the prompt
    #force_color_prompt=yes
    
    if [ -n "$force_color_prompt" ]; then
        if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
        else
        color_prompt=
        fi
    fi
    
    if [ "$color_prompt" = yes ]; then
        PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    else
        PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    fi
    unset color_prompt force_color_prompt
    
    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
    esac
    
    # enable color support of ls and also add handy aliases
    if [ -x /usr/bin/dircolors ]; then
        test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
        alias ls='ls --color=auto'
        #alias dir='dir --color=auto'
        #alias vdir='vdir --color=auto'
    
        alias grep='grep --color=auto'
        alias fgrep='fgrep --color=auto'
        alias egrep='egrep --color=auto'
    fi
    
    # some more ls aliases
    alias ll='ls -alF'
    alias la='ls -A'
    alias l='ls -CF'
    
    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    
    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
    
    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
        . /etc/bash_completion
    fi
    
    ###########################################
    # YOUR_USER_NAME'S CUSTOM CONFIGURATION BELOW:
    # Last edited: 09/07/2013
    # =========================================
    # Add /home/your_user_name/bin to PATH
        export PATH=$PATH:/home/your_user_name/bin
    #
    # END OF YOUR_USER_NAME'S CUSTOM CONFIGURATION
    ###########################################
    When you're satisfied that you've successfully edited your ~/.bashrc file, we need to load it with the following command:
    Code:
    source ~/.bashrc
    Quote Originally Posted by Langstracht View Post
    Thank you for your continued involvement.
    You're mighty welcome, Please follow the instructions I've given above very carefully. Please don't skip anything, especially making a copy of ~./bashrc before adding code to it.

    When you're done, please run the script again and let us know what happened.

    Thanks.
    Last edited by Crusty Old Fart; September 8th, 2013 at 03:48 AM. Reason: Removed references to "Jonathan". Had my threads confused. Sorry about that.
    Suffering from severe chronic female supervision deficiency syndrome resulting in
    an increasing intolerance of adolescent scatological effluence and PMS induced nefarious diatribe.
    How to: Mark your thread as: [SOLVED]

  10. #20
    Join Date
    Oct 2010
    Location
    Above ground...(for now)
    Beans
    761

    Re: Impossibilitus Interruptus ...

    Quote Originally Posted by steeldriver View Post
    ...BTW your posts would be much more readable if you used the [CODE]...[∕CODE] tags around your code
    Yup...sure as hell would be.
    Suffering from severe chronic female supervision deficiency syndrome resulting in
    an increasing intolerance of adolescent scatological effluence and PMS induced nefarious diatribe.
    How to: Mark your thread as: [SOLVED]

Page 2 of 3 FirstFirst 123 LastLast

Bookmarks

Posting Permissions

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