Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Shell script input and name completion?
Results 1 to 7 of 7

Thread: Shell script input and name completion?

Hybrid View

  1. #1

    Shell script input and name completion?

    I know I am probably turning into a pain, but... I was wondering... If I have a shell script, and it asks for the user's input, is it possible to somehow use name completion (like you would in a terminal), or does the user just have to enter every character?
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  2. #2
    Advisor Outlaw's Avatar
    Join Date
    May 2001
    Location
    Clifton Park, NY
    Posts
    630
    I don't think there's any shell builtin for that, but that would be a cool feature to implement. Challenging I bet.

    Check these out

    http://www.debian-administration.org/articles/317

    http://caliban.org/bash/

    Maybe somehow adapt that to reading user input
    Last edited by Outlaw; 06-15-2006 at 12:00 PM.

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  3. #3
    I'll take a look at these links, and see what can be done. It isn't really a neccessity, but boy, it sure would be handy...
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  4. #4
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    Just as a thought on this, couldn't something like this work:
    Code:
    #!/bin/sh
    echo -n "Select a person (ann, anna, able, anton) : "
    read CHOICE
    case "$CHOICE" in
        ann*)
            echo "Person starting with \"ann\" chosen"
            echo -n "Which do you mean (ann or anna)? : ann"
            CHOICE = "ann"
            read SEC_CHOICE
            echo "The selected persons name is: $CHOICE$SEC_CHOICE"
            ;;
        ant*)
            echo "Person starting with \"ant\" chosen"
            ;;
        ab*)
            echo "Person starting with \"ab\" chosen"
            ;;
        *)
            echo "Unknown person: \"$CHOICE\""
            ;;
    esac
    I know it won't provide autocorrection or interactiveness, but it will provide a pseudo way of guessing what the user is selecting.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

  5. #5
    I am not a CLI guru, but it looks like it could work... The project I was working on basically asked for the path of a file that you wish to alter. So, instead of having to type the entire path (i.e. /home/ron/documents/linux/advanced.bash.scripting.guide.htm, for example) I was trying to find a way to keep it shorter, yet accomodate any directory structure a user would have. I haven't really looked into to this too much since the last replies, as school is kicking my rump. Sometimes, I just think I am too old and set in my ways to go back to school...
    Asus A8V Deluxe Mobo
    AMD Athlon64 X2 4400 -939
    2GB Crucial DDR3200 Dual-Channel
    ATi AiW 9800 Pro 128DDR
    Audigy2 ZS
    Sony DRU-810 DVD+RW DL
    3 x Maxtor MaxLine SATA 160Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 300Gb 16Mb Cache
    1 x Maxtor MaxLine SATA 120Gb 16Mb Cache

  6. #6
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811
    Hmm.. making it fit any possible directory structure, dosn't sound feasible to me, since it would have to let the case portion automaticaly adjust to what is propossed, so it would programming wise be like saying
    P: Program, U: User
    P: What file to run ?
    U: /us<enter>
    P: We have /usr with underlying directories "bin", "doc", "games", "include", "src", "lib", ...
    P: Which one ? /usr/
    U: ga<enter>
    P: In /usr/games we have the following executable files, "tuxracer", "msfith", which do you chose?
    P: /usr/games/
    U: tu<enter>
    P: Running /usr/games/tuxracer
    This is from a scripting point of view extreemly improbable, it would require some way of reading a directory structure, and do a paternmatching on the given name..

    Ex. in C you would use opendir(3), readdir(3), scandir(3), seekdir(3) and closedir(3), but for a shell script I havn't encountered anything which does the same.
    Don't worry Ma'am. We're university students, - We know what We're doing.
    'Ruiat coelum, fiat voluntas tua.'
    Datalogi - en livsstil; Intet liv, ingen stil.

Similar Threads

  1. Shell script coding
    By lab in forum Programming
    Replies: 0
    Last Post: 07-14-2012, 05:18 AM
  2. Shell script coding
    By lab in forum Programming
    Replies: 0
    Last Post: 07-05-2012, 01:49 PM
  3. Shell script for geoiplookup cmd
    By Hariharan in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 10-19-2010, 10:18 AM
  4. Need of shell script
    By Hariharan in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 09-16-2010, 02:34 PM
  5. Shell script for monitoring
    By Hariharan in forum Linux - Software, Applications & Programming
    Replies: 0
    Last Post: 09-16-2010, 05:54 AM

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
  •