Find the answer to your Linux question:
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 24
You can pass the wildcards to the program by running GenerateIndex index.html "*.ps" "*.pdf" "*.txt" . (Ie. by quoting the wildcards. You can just as well use single quotes or ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578

    You can pass the wildcards to the program by running GenerateIndex index.html "*.ps" "*.pdf" "*.txt". (Ie. by quoting the wildcards. You can just as well use single quotes or backslashes.)
    Also, you sound like it would be something bad. If so, I just wanted to notify you that so is not the case. It is enormously convenient for application developers to have wildcards expanded when the program starts.

  2. #12
    Just Joined!
    Join Date
    Oct 2002
    Posts
    15
    He said no quotes are required. He told me there are ways to still do the program without quotes. :/ I cant think of how, because the shell automatically expands it BEFORE you can do anything...any ideas?

  3. #13
    Linux Engineer
    Join Date
    Jan 2003
    Location
    Lebanon, pa
    Posts
    994
    Ask him if you can do this in perl. I think it would be so much easier that way plus I can probably write it in about 10min

  4. $spacer_open
    $spacer_close
  5. #14
    Just Joined!
    Join Date
    Oct 2002
    Posts
    15
    Nope, we only start perl in the 7th week of class, not allowed right now

  6. #15
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    If he means that you would be able to index *.pdf in all subdirectories by just passing *.pdf non-quoted to the program, he is ultimately incorrect. It is possible if there are no pdf files in the directory in which you run the command, since the shell will pass wildcards if they match no files in the cwd, but I really don't think that that is what he means.
    I'll pass you a new script which indexes all subdirs with the filenames/wildcards passed as args, though:

    Code:
    #/bin/sh
    
    indexdir ()
    {
        for dir in $1; do
            if [ -d "$dir" ]; then
                (cd "$dir"; indexdir "@")
            fi
        done
        if [ -e "$indexname" ]; then
            return 0;
        fi
        cat >"$indexname" <<-EOF
            <html>
            <head><title>Index for `pwd`</title></head>
            <body>
    EOF
        while &#91;  $# -gt 0 &#93;; do
            for file in $1; do
                if &#91; -f "$file" &#93;; then
                    echo "<a href=\"$file\">$file</a>" >>"$indexname"
                fi
            done
            shift
        done
        cat >>"$indexname" <<-EOF
            </body>
            </html>
    EOF
    &#125;
    
    indexname="$1"
    shift
    if &#91; $# -eq 0 &#93;; then
        indexdir "*"
    else
        indexdir "$@"
    fi
    10 minutes, genlee? That's sloppy...

  7. #16
    Just Joined!
    Join Date
    Oct 2002
    Posts
    15
    Ya, I am sure thats what it means. I was thinking maybe you could put the expanded output into a file, and then take out only the extensions, and then work with that??


    As in, you would pass GenerateScript index.htm *.pdf *.ps

    and a file or something that would be made like the following:

    blah.pdf
    ps.ps

    so you could then take out the pdf and ps out of that....but thats way too much work I think for a homework.

    Thank you so much for the script

  8. #17
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I was thinking of such a solution as well, but that's really just stupid. Its' really easy, but it's quite a bad heuristic anyway. Say, for example, that you want to just index one or two given pdf names. In that case, that heuristic would index all pdf files, and apparently that's not what you want.

  9. #18
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    It is, of course, possible to turn of glob expansions in the shell, but noone wants to do that anyway, so I don't think he was referring to that either.

  10. #19
    Linux User
    Join Date
    Jul 2002
    Location
    Daytona Beach, FL
    Posts
    487
    Quote Originally Posted by Dolda2000
    If you would have looked at the address, you would have seen his user name there... I don't know if I am the one who should pick on things such as overlooking details, though... =)
    Now listen here, I just got back from Miami, after blowing my clutch down there... you be nice!
    majorwoo

    Quiet brain, or I\'ll stab you with a Q-tip.

  11. #20
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Oh, you poor thing! Did you have to stay in Miami? That must have been so hard on you... =)

Page 2 of 3 FirstFirst 1 2 3 LastLast

Posting Permissions

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