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.
Jag
Halfop
Posts: 90 Joined: Fri Sep 19, 2003 10:06 am
Post
by Jag » Mon Oct 20, 2003 8:44 am
How can i remove a specific line from a txt file in a command?
CrazyCat
Revered One
Posts: 1286 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Mon Oct 20, 2003 10:59 am
read each line:
if line matches => do nothing
if line doesn't match => put in tmp file
when eof, delete original file and rename tmp file as original.
Jag
Halfop
Posts: 90 Joined: Fri Sep 19, 2003 10:06 am
Post
by Jag » Mon Oct 20, 2003 11:12 am
CrazyCat wrote:
when eof, delete original file and rename tmp file as original.
how do i use the "eof" command?
can you give me an example please?
10x
GodOfSuicide
Master
Posts: 463 Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria
Post
by GodOfSuicide » Mon Oct 20, 2003 11:23 am
Code: Select all
set badtext "mybadtext"
set in [open myfile.txt "r"]
set out [open myfile.txt.tmp "w+"]
while {![eof $in]} {
set line [gets $in]
if {$line != $badtext} {
puts $out $line
}
}
close $in
close $out
exec "rm myfile.txt"
exec "cp myfile.txt.tmp myfile.txt"
exec "rm myfile.txt.tmp"
would remove every line that doesnt EXACT match with $badtext from a file.
you should do the file delete & rename stuff with the TCL Commands which have been written for this, i'm just too tired of looking them up.
Jag
Halfop
Posts: 90 Joined: Fri Sep 19, 2003 10:06 am
Post
by Jag » Mon Oct 20, 2003 12:38 pm
GodOfSuicide wrote: Code: Select all
exec "rm myfile.txt"
exec "cp myfile.txt.tmp myfile.txt"
exec "rm myfile.txt.tmp"
this commands are for eggdrop and not windrop, am i right?
CrazyCat
Revered One
Posts: 1286 Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:
Post
by CrazyCat » Mon Oct 20, 2003 12:58 pm
yes, I confirm
don't really know if it's possible with windrop...
Jag
Halfop
Posts: 90 Joined: Fri Sep 19, 2003 10:06 am
Post
by Jag » Mon Oct 20, 2003 1:47 pm
strikelight
Owner
Posts: 708 Joined: Mon Oct 07, 2002 10:39 am
Contact:
Post
by strikelight » Mon Oct 20, 2003 2:22 pm
change:
Code: Select all
exec "rm myfile.txt"
exec "cp myfile.txt.tmp myfile.txt"
exec "rm myfile.txt.tmp"
to:
Code: Select all
file delete myfile.txt
file rename myfile.txt.tmp myfile.txt
Jag
Halfop
Posts: 90 Joined: Fri Sep 19, 2003 10:06 am
Post
by Jag » Mon Oct 20, 2003 2:27 pm
10x !
Ofloo
Owner
Posts: 953 Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:
Post
by Ofloo » Tue Oct 21, 2003 7:13 pm
this commands are for eggdrop and not windrop, am i right?
Yes you can if you use "-n" option on start but this will move the bot into forground, if you install your eggdrop as a service then you won't have the forground proces
well it won't show any way but don't make it interact with your desktop
XplaiN but think of me as stupid
Ofloo
Owner
Posts: 953 Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:
Post
by Ofloo » Tue Oct 21, 2003 7:30 pm
and why use exec ???
Code: Select all
#Usage: [badtext:filter mytextfile.txt badtext]
proc badtext:filter {filename badtext} {
set rfile [open "$filename" "r"]
set wfile [open "tmp/$filename.tmp" "w"]
while {![eof $rfile]} {
gets $rfile line
if {![string match -nocase "*$badtext*" $line]} {
puts $wfile $line
}
}
close $rfile
close $wfile
set rfile [open "tmp/$filename.tmp" "r"]
set wfile [open "$filename" "w"]
foreach line [split [read $rfile] \n] {
puts $wfile $line
}
close $rfile
close $wfile
}
and from what i can say this is os independent
XplaiN but think of me as stupid
GodOfSuicide
Master
Posts: 463 Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria
Post
by GodOfSuicide » Wed Oct 22, 2003 1:25 am
Ofloo wrote: and why use exec ???
and why use 5 files for your ip-to-country script?
somethimes ppl are just too lazy (i know i am)
Ofloo
Owner
Posts: 953 Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:
Post
by Ofloo » Wed Oct 22, 2003 5:38 am
well its written in the top thats its crapy code and needs rewrite :p can't say lazy more like if i don't know stuff i work arround it ! on my way so .. more like inventive :p but hell not saying your scripting is bad just trying to help out :p sorry if you took it personal
XplaiN but think of me as stupid
Ofloo
Owner
Posts: 953 Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:
Post
by Ofloo » Wed Oct 22, 2003 5:47 am
GodOfSuicide wrote: And why use 5 files for your ip-to-country script?
and if you do got suggestions plz post :p, and for futur suggestions use email in the top of the script.
XplaiN but think of me as stupid