| View previous topic :: View next topic |
| Author |
Message |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Sun Sep 24, 2006 1:53 pm Post subject: [SOLVED] Search for files via Eggdrop |
|
|
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 |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Sun Sep 24, 2006 2:57 pm Post subject: |
|
|
| 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 |
|
 |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Sun Sep 24, 2006 3:33 pm Post subject: |
|
|
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 |
|
 |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Sun Sep 24, 2006 3:58 pm Post subject: |
|
|
Ok...
concat is false
i replaced that with exec
| 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
Best regards
tessa1 |
|
| Back to top |
|
 |
metroid Owner
Joined: 16 Jun 2004 Posts: 771
|
Posted: Mon Sep 25, 2006 1:46 am Post subject: |
|
|
| 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 |
|
 |
tessa1 Halfop
Joined: 18 Apr 2005 Posts: 49 Location: Germany
|
Posted: Mon Sep 25, 2006 12:45 pm Post subject: |
|
|
Many thanks...
this code works for me
| 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 |
|
 |
|