egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] Search for files via Eggdrop

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Sun Sep 24, 2006 1:53 pm    Post subject: [SOLVED] Search for files via Eggdrop Reply with quote

Hi,

i need a a small dj-searchscript that displays the path from a file on my shell.

When i type this in my shell:
Quote:
root:~# find /home/dj/djpool -iname "*What is Love*"


putty displays the following result:
Quote:
/home/dj/djpool/H/Haddaway/2nd Edition/Haddaway-00_What is Love.mp3
/home/dj/djpool/H/Haddaway/2nd Edition/Haddaway-05_What is Love (Rapino-Brothers-Mix).mp3


What i want to do, is to display the result in an IRC-Channel when i type

!find what is love

should the bot display:

/home/dj/djpool/H/Haddaway/2nd Edition/Haddaway-00_What is Love.mp3

/home/dj/djpool/H/Haddaway/2nd Edition/Haddaway-05_What is Love (Rapino-Brothers-Mix).mp3


Best regards
tessa1


Last edited by tessa1 on Mon Sep 25, 2006 12:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Sun Sep 24, 2006 2:57 pm    Post subject: Reply with quote

I know this is the scripts request forum, and you probably want a whole working script. I just thought I'd point out that the manpage for "file" for tcl has an example of a filesearch script (although not specifically for eggdrop output.)
Back to top
View user's profile Send private message
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Sun Sep 24, 2006 3:33 pm    Post subject: Reply with quote

Hm... something like this?

Thats untested and i dunno if it works.

Code:

bind pub "-|-" !find find_proc
proc find_proc {nick uhost handle channel arg} {
 set num [lindex [split $arg] 0 end]
 set command [concat find /home/dj/djpool -iname *$num*]
 set return [eval $command]

 foreach output [split $return \n] {
  putserv "PRIVMSG $channel :\002$output\002"
 }
}


Best regards
tessa1
Back to top
View user's profile Send private message
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Sun Sep 24, 2006 3:58 pm    Post subject: Reply with quote

Ok...

concat is false

i replaced that with exec Wink

Code:
bind pub "-|-" !find find_proc
proc find_proc {nick uhost handle channel arg} {
 set num [lindex [split $arg] 0 end]
 set command [exec find /home/dj/djpool -iname *$num*]
 set return [eval $command]
  foreach output [split $return \n] {
  putserv "PRIVMSG $channel :$output"
 }
}


But don't works because the output begins with /home/blaaaaa...

Quote:

Tcl error [find_proc]: invalid command name "/home/dj/djpool/H/test.txt"


Plz help me a little bit Smile

Best regards
tessa1
Back to top
View user's profile Send private message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Mon Sep 25, 2006 1:46 am    Post subject: Reply with quote

Code:
bind pub -|- !find find_proc
proc find_proc {nick uhost handle channel arg} {
  set results [glob -nocomplain /home/dj/djpool/*[lrange [split $arg] 0 end]*]

  if {[llength $results]} {
    foreach result $results {
      putserv "PRIVMSG $channel :\002[file tail $result]\002"
    }
  } else {
    putserv "PRIVMSG $channel :Found no results."
  }
}


If you want it to state the entire path (no idea why you would want that)

Change

Code:
putserv "PRIVMSG $channel :\002[file tail $result]\002"


into

Code:
putserv "PRIVMSG $channel :\002$result\002"



(untested)
Back to top
View user's profile Send private message
tessa1
Halfop


Joined: 18 Apr 2005
Posts: 49
Location: Germany

PostPosted: Mon Sep 25, 2006 12:45 pm    Post subject: Reply with quote

Many thanks...

this code works for me Wink

Code:

set filepath "/path/to/dirctory"

bind pub -|- !find find_proc
proc find_proc {nick uhost handle channel arg} {
  set results [exec find $filepath -iname *[lindex [split $arg] 0 end]*]

  if {[llength $results]} {
    foreach result $results {
      putserv "PRIVMSG $channel :\002$result\002"
    }
  } else {
    putserv "PRIVMSG $channel :\002No results\002"
  }
}


Best regards
tessa1
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber