Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: How can I get input from terminal?

  1. #11
    Join Date
    Apr 2008
    Beans
    246

    Re: How can I get input from terminal?

    Quote Originally Posted by jpkotta View Post
    You sure about that? Aliases don't take arguments. It will work, but only because -ncycles is the last option and $1 is unbound. What aliases do is a strict substitution of whatever the alias is. There isn't any shell expansion.
    Ah yes, you are correct. I always forget that.

  2. #12
    Join Date
    Jun 2009
    Location
    0000:0400
    Beans
    Hidden!

    Re: How can I get input from terminal?

    Quote Originally Posted by jpkotta View Post
    You sure about that? Aliases don't take arguments. It will work, but only because -ncycles is the last option and $1 is unbound. What aliases do is a strict substitution of whatever the alias is. There isn't any shell expansion.
    Sorry but I don't buy that. I use the following alias (bash) and it works as intended:
    Code:
    man2pdf() {
        if [ -z $1 ]; then
            echo "USAGE: man2pdf [manpage]"
        else
            if [ `find /usr/share/man -name $1\* | wc -l` -gt 0 ]; then
                out=/tmp/$1.pdf
                if [ ! -e $out ]; then
                    man -t $1 | ps2pdf - > $out
                fi
                if [ -e $out ]; then
                    /usr/bin/evince $out
                fi
            else
                echo "ERROR: manpage \"$1\" not found."
            fi
        fi
    }
    Omitting an argument prints the usage message. Maybe I'm misunderstanding your explanation.

  3. #13
    Join Date
    Apr 2008
    Beans
    246

    Re: How can I get input from terminal?

    falconindy: What you pasted is a function. jpkotta is referring to aliases, defined by "alias <name>='<command>'".

  4. #14
    Join Date
    Jun 2009
    Location
    0000:0400
    Beans
    Hidden!

    Re: How can I get input from terminal?

    Quote Originally Posted by linkmaster03 View Post
    falconindy: What you pasted is a function. jpkotta is referring to aliases, defined by "alias <name>='<command>'".
    Silly me. I should have known that.

  5. #15
    Join Date
    Sep 2009
    Beans
    18

    Re: How can I get input from terminal?

    I'm totally lost. Tried the last one but still getting bracket error's can someone explain the algorithm to me in a easy way maybe i can modify the code?
    By the way one of my friends send me something like this:
    Code:
    #!/bin/bash
    
    echo "First Number"
    echo $1
    echo "Second Number"
    echo $2
    echo "number of the totals"
    let result=$1+$2
    echo $result
    echo
    # -------------------------- #
    echo -n "Enter another value: "
    read var
    echo "\"var\" = "$var""
    # IS IT OK?
    ubuntu doesnot take sonuc as a variable..
    Is it possible to modify this code to enter the number to the end of a string?

Page 2 of 2 FirstFirst 12

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
  •