6

I am searching for a lightweight solution for helping users finding files on my server.

Running on commandline I can just use locate, if necessary piped with a grep command. However the users do not have access to the prompt and do not have the knowledge to use more complicated piped commands.
I have been experimenting with some search engines like solr and opensearch, however these are quite demanding on recourses for full hd's with lots of data, while most of the times a simple name search will suffice.

Does anyone know a web gui which can just make use of the existing locatedb?
Or an other approach, like a lightweight searchengine, with low setup effort and limited resource demands which uses a central search db and provide a gui to different platforms?

Requist
  • 2,389
  • 2
  • 22
  • 32
  • Perhaps https://github.com/kaazoo/weblocate? Does it have to be web? – muru Jan 26 '15 at 17:24
  • If it is able to provide a GUI to different platforms it does not necessary has to be web-based. I'll have a look at weblocate. – Requist Jan 26 '15 at 17:57
  • You may want to give a try to gnome-search-tool – jasmines Jan 27 '15 at 08:07
  • Something in the name makes me believe gnome-search-tool is not multi-platform, or does this have a kind of web-service in the background? – Requist Jan 27 '15 at 16:14
  • Actually solr is as lightweight as it can get when used right. You can set it up to just index the file names. The demanding part then is not on the hardware, but on your part though to configure it and provide a search UI :-) – Harald Jan 28 '15 at 18:45
  • If you give me a detailed description of the exact features you want to have, I maybe could code you a small GUI frontend for the CLI commands in Java. A list of possible request types and what would have to be typed into the terminal for them would be the best. I am familiar with piping and stuff, but never had to use locate yet. Please write me a comment if you're interested. – Byte Commander Jan 30 '15 at 08:13
  • Please refer to my updated answer below – Sergiy Kolodyazhnyy Jan 31 '15 at 06:20
  • is this more for mobile or for all devices in general ?! - – dschinn1001 Feb 02 '15 at 09:02
  • It would be more for general use / different platforms. Users could consult the search-results from all available files and fetch them by use of ftp, smb, web or whatever. – Requist Feb 03 '15 at 14:23
  • @ByteCommander Thanks for the offer. However I was hoping on a ready product instead. I am just a bit amazed that it does not appear to exist. – Requist Feb 03 '15 at 14:36
  • Cannot comment: gnome-open is completely replacable with xdg-open Is now: /usr/bin/xdg-open "$TOPEN" >/dev/null 2>&1 & To prohibit output and command overwriting, also to start as background job. OT: Will delete if updated or we together decide to /bin/fck /sys – xtf Nov 27 '18 at 23:41

4 Answers4

7

Update, January 22,2018:

I have stumbled upon mlocate-web on GitHub, which fits OP's requirements quite well, although lacks ability to open files. Can be ran manually or as daemon. According to the README.md, the package was developed on Ubuntu 16.04, so it's quite recent as of right now.

Mini-update, Feb 2

Added double quotes to gnome-open "$TOPEN", so that gnome-open gets full pathname of files that have space.

Update # 2,Jan 30 :

As requested in the comments , I've refined the script, and added the option to open files. Everything is implemented with zenity, locate, and gnome-open. Praise the Unix philosophy of piping commands into others !

I've annotated the script , so it should be clear where, what, and how. In the screenshots I'm opening the Hello World program for java. The script exits at any point if user clicks Cancel/Quit buttons.

Side note: The OP requested that the app should be cross-platform. As far as I know, zenity,gnome-open, and locate are not dependent on presence of GNOME shell. Besides, users will be connecting to his Ubuntu server, and all those apps work on Ubuntu regardless of GNOME shell's presence. In other words, they're going to be executing the script on his system, not theirs, to locate the files.

The refined script:

#!/bin/bash
# Author: Serg
# Description: GUI using zenity for locate utility
# Date: January 30, 2015

# This flag will make popup appear if nothing was found
FOUND=0

# Ask user for input, and store it in USRFILE variable
USRFILE=`zenity --entry --title="SEARCH"  --entry-text="Text here" --text="Enter a filename or part of it"`

# if use clicked OK, proceed to this big if statement
if [ $(echo $?) = 0 ]
    then
    TOPEN=$( ( locate $USRFILE ) | ( zenity --height 450 --width=450\
     --list --column "Please wait, I'll display paths to files, if I find any"\
     --title "SEARCH RESULTS" --text "Select a file you want to open"\
    --height=450 --width=450 --ok-label="Open a file " --cancel-label="Quit" )  )
    # FIXME: if user clicks open a file without selecting one, program will crash
    # FIXME: selecting a file and hitting enter, brings up "Nothing found" dialog

    # If user clicked "Open a file" , gnome-open 
    # will open it with whatever default
    # program is listed for that file-type
    if [ $(echo $?) = 0 ]
        then
        gnome-open "$TOPEN"
    fi


    # Set flag to true, do not display "Nothing found"
    if [ $(echo $?) = 0 ] 

        then FOUND=1

    fi

    # If we didn't  find anything, display a message
    if [ $FOUND != 1  ]
        then zenity --info --text="Nothing found"
    fi

fi

Screenshots of the refinements

Get user input enter image description here Display search results if any, might take a moment to load enter image description here Open the selected file enter image description here

For a suggestion on how to make this script open with a short-cut (double-click), refer to my previous update below

Update #1,Jan 29 : Disregard my previous post. I've though about the way you worded the problem : "a gui front end to locate". In fact there exists a gui front end to scripts , zenity, and I've used it to make a rough draft of a script that might be useful. Feel free to alter it and add functionality, but at the most basic level it's locate with gui.

As for making a script "double-clickable" refer here

The script

#!/bin/bash

FOUND=0


USRFILE=`zenity --entry  --entry-text="Text here" --text="Enter a filename or part of it"`
zenity --info --text " Please wait a little, I'll try to find it "
locate $USRFILE > results.txt && zenity --text-info --html --filename='results.txt' 
if [ -e results.txt ] 
        then FOUND=1
        rm results.txt
fi

if [ $FOUND != 1  ]
         then zenity --info --text="Nothing found"
fi

Screenshots

enter image description here enter image description here enter image description here enter image description here enter image description here

Old post

There is gnome-search-tool, which I've checked with ps and htop utilities and it doesn't take too many resources. You can install it with sudo apt-get install gnome-search-tool.

enter image description here

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • Once you find the results, is it possible to click on one and have it open with it's default app? Example: text files - gedit, audio/video - vlc, html - firefox, etc. Also a right click to show 'containing directory' would be nice. – Parto Jan 30 '15 at 15:52
  • Currently, no. Like I said, its basically locate command implemented with series of pop ups. Now, there's gnome-open command which will open a file you've given it with default program, eg gnome-open screenshot.png opens screenshot.png with image-magic on my system. But it will require a separate popup. User would have to copy the path to file and paste in that popup. I will work on this idea, but currently - that's all I can offer. Best thing about it is that this script requires no additional software installation – Sergiy Kolodyazhnyy Jan 30 '15 at 21:34
  • @Parto I've refined the script. Now it opens files as well. Refer to my updates above – Sergiy Kolodyazhnyy Jan 31 '15 at 06:07
  • Cool. +1 then for the good job. – Parto Jan 31 '15 at 06:15
  • Well, this is not exactly what I had in mind. My question was actually for a web-gui which could make use of the locatedb; to keep the solution more open I added an alternative which could provide a gui to different platforms could be considered. This solution would require access to the desktop and is not really multiplatform? I awarded the bounty anyway, but ATM I do not accept it as the correct answer to my question. – Requist Feb 03 '15 at 14:18
  • @Requist Thank you, first of all. Second, is there an example of what you had in mind ? Maybe people here are not exactly catching the idea – Sergiy Kolodyazhnyy Feb 03 '15 at 17:45
  • @Serg What I meant is just a kind of google webpage connecting to the locatedb of my server. But instead of web it could also be for example a java client which connects from a client pc and does a query. – Requist Feb 03 '15 at 19:27
  • @Requist Ah, I get the idea. It could be a web-page on apache server, with cgi script, which would use bash or python script that could then call locate. But I've never messed with apache yet, so at this moment I can't be much helpful in this department. – Sergiy Kolodyazhnyy Feb 03 '15 at 23:44
  • This simple script is more useful for my needs than catfish. It uses locate only and not find, and opens the file with the default application and not necessarily with Thunar. For LXQt, i changed gnome-open to xdg-open and added an option with pcmanfm-qt $(dirname "$TOPEN") to open the containing folder instead of the file – golimar Jun 30 '22 at 12:14
0

I know this is pretty old but I just found myself asking the same question for some cold storage on a Raspberry Pi. I came up with a super simple solution with CGI but beware - security isn't its strength. Only use this for a personal system or private network because it's ripe for injection attacks. The good news is it's fast and easy to deploy if you already have Apache/NGinx installed.

search.html:

<HTML>
<TITLE>MLocate Web Form</TITLE>
<BODY>
<b>Simple Web Form</b><p>
<FORM ACTION="/cgi-bin/search.cgi" target="resultsframe">
<label for="search">Find</label>
<INPUT TYPE="TEXT" NAME="search" SIZE="50"><BR>
<label for="limit">Limit</label>
<INPUT TYPE="TEXT" NAME="limit" value="10" SIZE="4"><BR>
<INPUT TYPE="SUBMIT" NAME="Find" VALUE="Find">
</FORM>
<iframe name="resultsframe" height=600 width=800></iframe>
</BODY>
</HTML>

Now you can just use CGI to dump the results from a bash script (/var/www/cgi-bin/search.cgi):

#!/bin/bash
echo -e 'Content-type: text/html\n\n'
echo '<html><body><table>'

eval $(echo $QUERY_STRING | sed 's/\&/\n/g')

while read -r l
do
    l=${l:8}
    echo "<tr><td><a href='[YOUR_HTTP_BASE]$l'>$l</td></tr>"
done <<< $(locate -l "$limit" -i "$search")

echo "</table></html>"

Results are posted as links so filter and map your results to apache-permitted paths you want. If you have unicode or html-iffy characters, best to escape them. Also note that you can potentially inject nastiness into your search here so use at your own risk or sterilize the input.

Sample screenshot

BoeroBoy
  • 131
0

I using zenity. Configured the search for text in the folder via Thunar

If someone will help this will only be happy

#!/bin/bash
# Author: Karavaev Viktor E. (Russia)

# Description: GUI using zenity for locate search file Thunar
# Using Thunar: ~/.config/Thunar/find_file_thunar.sh %f
# Using: ~/.config/Thunar/find_file_thunar.sh /home/user/dir/
# Date: June 05, 2020
# print debug strings
debug=0

# Find is dir
FINDSTR=$1

if [ $debug = 1 ]
then
    echo $FINDSTR
fi

# open window without exit
zenity_list()
{
    TOPEN=$( zenity --height=400 --width=450 \
         --list --column "Files" \
         --title "Result" --text "Select the file you want to open" \
         --ok-label="Open" --cancel-label="Close" --separator=";" $list  )

    if [ $(echo $?) = 0 ]
    then
        if [ "$debug" = 1 ]
        then
            echo "TOPEN: $TOPEN \n"
        fi
        # Open select file this program ( i like geany ;) )
        geany "$TOPEN"
        zenity_list

    fi   
}

# Find is dir exist
if [ -n "$FINDSTR" ]
then

    # This flag will make popup appear if nothing was found
    FOUND=0

    cd $FINDSTR

    # Ask user for input, and store it in USRFILE variable 
    USRFILE=`zenity --entry --title="Search"  --entry-text="" --text="search text"`


    if [ "$debug" = 1 ]
    then    
        # dir search command
        grep -rnwil "$USRFILE"
    fi  

    # if use clicked OK, proceed to this big if statement
    if [ $(echo $?) = 0 ]
        then

        list=$( grep -rnwil "$USRFILE" )

        if [ "$debug" = 1 ]
        then            
            echo "list finds:  $list \n"
        fi      
        zenity_list 

        # Set flag to true, do not display "Nothing found"
        if [ $(echo $?) = 0 ] 
            then FOUND=1
        fi

    fi

    # If we didn't  find anything, display a message
    if [ "${#list[@]}" = 0 ]    
    then
        if [ "$debug" = 1 ]
        then            
            echo "Not found \n"
        fi  
        zenity --height=100 --width=200 --info --text="Not found "
    fi  

if [ "$debug" = 1 ]
then             
    echo "flag FOUND result: $FOUND \n"
fi  

else
    if [ "$debug" = 1 ]
    then            
        echo "Parameters were not found. \n"
    fi
    zenity --height=100 --width=200 --info--text="Parameters were not found."
fi

enter image description here

Kulfy
  • 17,696
0

I have made my research about this , found out this versatile file searching tool called Catfish. Sounds promising, completely written in python and helpful to find and locate files. I also found a GUI

Luís de Sousa
  • 13,227
  • 26
  • 81
  • 128
Hashes
  • 1
  • 1
  • 1
    unfortunately, catfish also automatically fires find() which eats up cpu and needs to be cancelled manually – phil294 Dec 06 '19 at 18:26