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.
Old posts that have not been replied to for several years.
Pitchat
Op
Posts: 122 Joined: Tue Feb 18, 2003 11:24 pm
Location: Hebertville Quebec Canada
Contact:
Post
by Pitchat » Tue Nov 18, 2003 11:27 pm
Hi again !
i use a little scripts that is some sort of "skool.tcl" scripts but it was made for linux eggdrop and i have an error wich is cause by the " exec" commands , i isolate the proc responsible and i`d like to know how can i do the same thing without using the exec command ( you must have guessed , i`m on windows ! )
heres the error
[22:10] (Espion): [22:10] Tcl error [dcc:cours]: couldn't execute "ls": no such file or directory
thanks
Pitchat
Code: Select all
set cours(path) "scripts/cours"
set cours(chan) "#pitchat"
bind dcc o cours dcc:cours
proc dcc:cours {hand idx arg} {
if {[info proc cours:[lindex $arg 0] ] == ""} {
putdcc $idx "###Syntaxe: .cours <go|stop|list> <arg>"
return 0
} {
cours:[lindex $arg 0] $hand $idx $arg
}
}
proc cours:go {hand idx arg} {
global line cours botnick
if {![file exists "$cours(path)/[lindex $arg 1].cours"]} {
cours:list $hand $idx $arg
return 0
}
set coursfile [open "$cours(path)/[lindex $arg 1].cours" r]
set cours(totline) 0
while {![eof $coursfile]} {
set cours(totline) [expr $cours(totline) +1]
set line($cours(totline)) [gets $coursfile]
}
putdcc $idx "Loaded ($cours(totline) lines)"
setuser $botnick xtra COUR "actif"
set cours(nb) "1"
cours:disp
close $coursfile
}
proc cours:disp {} {
global timer line cours
if {$cours(nb) < $cours(totline)} {
putserv "PRIVMSG $cours(chan) :$line($cours(nb))"
set cours(nb) [expr $cours(nb)+1]
set tmp "cours:disp"
set timer [utimer 30 $tmp]
} {
putserv "PRIVMSG $cours(chan) :End"
}
}
proc cours:stop {hand idx arg} {
global timer cours
if {[info exists timer]} {
killutimer $timer
putdcc $idx "Oki"
putserv "NOTICE $cours(chan) :CLASS STOPPED BY $hand"
}
}
proc cours:list {hand idx arg} {
global cours
putdcc $idx "Cours files"
foreach liste [exec ls $cours(path)] {
if {[string match "*.cours" $liste]} {
putdcc $idx "[lindex [split $liste .] 0]"
}
}
putdcc $idx "end"
}
user
Posts: 1452 Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway
Post
by user » Wed Nov 19, 2003 4:25 am
use
glob instead of 'exec ls'
Have you ever read "The Manual"?
Pitchat
Op
Posts: 122 Joined: Tue Feb 18, 2003 11:24 pm
Location: Hebertville Quebec Canada
Contact:
Post
by Pitchat » Wed Nov 19, 2003 7:09 am
i have replace the exec ls thing with glob but instead of en error a have this
Code: Select all
[04:12] (Pitchat): .cours list
[04:12] (Espion): Cours files
[04:12] (Espion): end
and it doesnt lisdt the files in the directory ( /scripts/cours )
i read the glob page but i do not figure how to apply this in my script since i am quite new at tcl
Code: Select all
proc cours:list {hand idx arg} {
global cours
putdcc $idx "Cours files"
foreach liste [glob $cours(path)] {
if {[string match "*.cours" $liste]} {
putdcc $idx "[lindex [split $liste .] 0]"
}
}
putdcc $idx "end"
}
thanks
user
Posts: 1452 Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway
Post
by user » Wed Nov 19, 2003 8:05 am
Code: Select all
proc cours:list {hand idx arg} {
global cours
putdcc $idx "Cours files"
foreach liste [glob -nocomplain -dir $cours(path) *.cours] {
putdcc $idx [file tail [file rootname $liste]]
}
putdcc $idx "end"
}
If -dir doesn't work, use [file join $cours(path) *.cours] instead
Have you ever read "The Manual"?
Pitchat
Op
Posts: 122 Joined: Tue Feb 18, 2003 11:24 pm
Location: Hebertville Quebec Canada
Contact:
Post
by Pitchat » Wed Nov 19, 2003 1:14 pm
still doesnt work in this form
Code: Select all
set cours(path) "scripts/cours/"
set cours(chan) "#pitchat"
bind dcc o cours dcc:cours
proc dcc:cours {hand idx arg} {
if {[info proc cours:[lindex $arg 0] ] == ""} {
putdcc $idx "###Syntaxe: .cours <go|stop|list> <arg>"
return 0
} {
cours:[lindex $arg 0] $hand $idx $arg
}
}
proc cours:go {hand idx arg} {
global line cours botnick
if {![file exists "$cours(path)/[lindex $arg 1].cours"]} {
cours:list $hand $idx $arg
return 0
}
set coursfile [open "$cours(path)/[lindex $arg 1].cours" r]
set cours(totline) 0
while {![eof $coursfile]} {
set cours(totline) [expr $cours(totline) +1]
set line($cours(totline)) [gets $coursfile]
}
putdcc $idx "Loaded ($cours(totline) lines)"
setuser $botnick xtra COUR "actif"
set cours(nb) "1"
cours:disp
close $coursfile
}
proc cours:disp {} {
global timer line cours
if {$cours(nb) < $cours(totline)} {
putserv "PRIVMSG $cours(chan) :$line($cours(nb))"
set cours(nb) [expr $cours(nb)+1]
set tmp "cours:disp"
set timer [utimer 30 $tmp]
} {
putserv "PRIVMSG $cours(chan) :End"
}
}
proc cours:stop {hand idx arg} {
global timer cours
if {[info exists timer]} {
killutimer $timer
putdcc $idx "Oki"
putserv "NOTICE $cours(chan) :CLASS STOPPED BY $hand"
}
}
proc cours:list {hand idx arg} {
global cours
putdcc $idx "Cours files"
foreach liste [glob -nocomplain -dir $cours(path) *.cours]
{
putdcc $idx [file join $cours(path) *.cours]
}
putdcc $idx "end"
}
i really dont know where to look now
thanks for your efforts
user
Posts: 1452 Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway
Post
by user » Wed Nov 19, 2003 1:53 pm
Pitchat wrote: Code: Select all
proc cours:list {hand idx arg} {
global cours
putdcc $idx "Cours files"
foreach liste [glob -nocomplain -dir $cours(path) *.cours]
{
putdcc $idx [file join $cours(path) *.cours]
}
putdcc $idx "end"
}
...if that's what your code looks like, no wonder (the extra line breaks before the body of the foreach
) This is what I meant:
Code: Select all
proc cours:list {hand idx arg} {
global cours
putdcc $idx "Cours files"
foreach liste [glob -nocomplain [file join $cours(path) *.cours]] {
putdcc $idx "[file tail [file rootname $liste]]"
}
putdcc $idx "end"
}
If it still doesn't work, check your path and working directory. Giving an absolute path would be best, as the working directory won't matter then.
Have you ever read "The Manual"?
Pitchat
Op
Posts: 122 Joined: Tue Feb 18, 2003 11:24 pm
Location: Hebertville Quebec Canada
Contact:
Post
by Pitchat » Wed Nov 19, 2003 2:36 pm
heres the result with your code
[13:29] (Pitchat): .cours list
[13:29] (Espion): Cours files
[13:29] (Espion): end
the directory his /scripts/cours and there is 3 files already in there