This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
tessa1
Halfop
Posts: 49 Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany
Post
by tessa1 » Sun Sep 24, 2006 1:53 pm
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:
root:~# find /home/dj/djpool -iname "*What is Love*"
putty displays the following result:
/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.
rosc2112
Revered One
Posts: 1454 Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania
Post
by rosc2112 » Sun Sep 24, 2006 2:57 pm
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.)
tessa1
Halfop
Posts: 49 Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany
Post
by tessa1 » Sun Sep 24, 2006 3:33 pm
Hm... something like this?
Thats untested and i dunno if it works.
Code: Select all
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
tessa1
Halfop
Posts: 49 Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany
Post
by tessa1 » Sun Sep 24, 2006 3:58 pm
Ok...
concat is false
i replaced that with exec
Code: Select all
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...
Tcl error [find_proc]: invalid command name "/home/dj/djpool/H/test.txt"
Plz help me a little bit
Best regards
tessa1
metroid
Owner
Posts: 771 Joined: Wed Jun 16, 2004 2:46 am
Post
by metroid » Mon Sep 25, 2006 1:46 am
Code: Select all
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: Select all
putserv "PRIVMSG $channel :\002[file tail $result]\002"
into
Code: Select all
putserv "PRIVMSG $channel :\002$result\002"
(untested)
tessa1
Halfop
Posts: 49 Joined: Mon Apr 18, 2005 12:51 pm
Location: Germany
Post
by tessa1 » Mon Sep 25, 2006 12:45 pm
Many thanks...
this code works for me
Code: Select all
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