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!
Meropie
Voice
Posts: 7 Joined: Wed Dec 19, 2007 10:02 am
Post
by Meropie » Tue Feb 05, 2008 10:44 am
hello, im searching for a snippet to delete a line from a file.
my file looks like:
bla
bla2
bla4
meropie
egghelp
and such..
i want to delete a line, but i am searching the whole line, so it will be much easier (i think).
example:
i want to delete meropie, i will search for meropie and delete it so the file will look like:
bla
bla2
bla4
egghelp
.
thanks.
Maiki
Voice
Posts: 28 Joined: Sun May 20, 2007 4:58 pm
Post
by Maiki » Tue Feb 05, 2008 10:51 am
Code: Select all
bind pub - !delete delLine
proc delLine {nick uhost hand chan arg} {
set file [open /usr/dir r]
set data [read -nonewline $file]
close $file
if {[set pos [lsearch -glob [set ldata [split $data \n]] $arg]] != -1} {
set data [open /usr/dir w]
puts $data [join [lreplace $ldata $pos $pos] \n]
close $data
putserv "PRIVMSG $chan :Deleted $arg"
} else {
close $data
putserv "PRIVMSG $chan :Can not find $arg in the file"
}
}
Meropie
Voice
Posts: 7 Joined: Wed Dec 19, 2007 10:02 am
Post
by Meropie » Tue Feb 05, 2008 10:57 am
yo, thanks for the help, but error accurs:
[16:57] Tcl error [delLine]: can not find channel named "Meropie"
Maiki
Voice
Posts: 28 Joined: Sun May 20, 2007 4:58 pm
Post
by Maiki » Tue Feb 05, 2008 11:03 am
Fixed..
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Tue Feb 05, 2008 2:36 pm
Check out user's code in
this thread.