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 

hi, a snippet is needed.

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


Joined: 19 Dec 2007
Posts: 7

PostPosted: Tue Feb 05, 2008 10:44 am    Post subject: hi, a snippet is needed. Reply with quote

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.
Back to top
View user's profile Send private message
Maiki
Voice


Joined: 20 May 2007
Posts: 28

PostPosted: Tue Feb 05, 2008 10:51 am    Post subject: Reply with quote

Code:
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"

        }

}
Back to top
View user's profile Send private message
Meropie
Voice


Joined: 19 Dec 2007
Posts: 7

PostPosted: Tue Feb 05, 2008 10:57 am    Post subject: Reply with quote

yo, thanks for the help, but error accurs:
[16:57] Tcl error [delLine]: can not find channel named "Meropie"
Back to top
View user's profile Send private message
Maiki
Voice


Joined: 20 May 2007
Posts: 28

PostPosted: Tue Feb 05, 2008 11:03 am    Post subject: Reply with quote

Fixed.. Smile
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Tue Feb 05, 2008 2:36 pm    Post subject: Reply with quote

Check out user's code in this thread.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
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