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.

need help with backup script

Old posts that have not been replied to for several years.
Locked
j
jedis

Post by jedis »

Hi.

I am attempting to get my Bot to perform a backup of it's quote file nightly. The script below works, except for a couple problems.

It executes fine, but after it's done, it gives me an error: TCL error [dcc_quotebackup]: invalid command name "0". However, the DCC send goes through and my other bot receives it. Once the backup bot has the file though, it will not work on subsequent backups, error: 'File `quotes' already exists.' Is there any way around this?

Code: Select all

## Quote file backup tcl
#  by jedis

set backup_bot Bot1
set quote_backupfile "/path/to/quotes"

bind time - "58 24 * * *" dcc_quotebackup

proc dcc_quotebackup {x1 x2 x3 x4 x5} {
 global backup_bot quote_backupfile
  dccbroadcast "Backing up our beloved quote file! (RIP Quotey)"
   [dccsend $quote_backupfile $backup_bot]
  return
}
<font size=-1>[ This Message was edited by: jedis on 2002-01-04 20:51 ]</font>
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Do not surround the line
[dccsend $quote_backupfile $backup_bot]
with [] chars.

In this situation, it evaluates the command dccsend. This is returning the number 0, to everything went fine.

Becuase the [] replaces what was there, with the return value, all that is left is 0, which does not exist.
j
jedis

Post by jedis »

Aha, gotcha.

Any thoughts on how to make the eggdrop overwrite a file if it already exists in the filesystem?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Depends how you made it write in the first place.

somthing like

Code: Select all

set file "/path/to/file/to/overwrite"
set fp [open $file w]
flush $fp
close $fp
if you opened the file, and wrote to it with Tcl commands, or used a third party sciprt/application.
j
jedis

Post by jedis »

Would this work with a remote bot though? It needs to overwrite the backup quote file in the remote Bot's dcc filesystem.

Wouldn't that only work locally?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Yes, but a small botnet script, would solve this issue.

EG, local bot

Code: Select all

putbot <remote-bot> "CLFILE"
remote bot

Code: Select all

bind bot - "CLFILE" clfile:remote
proc clfile:remote {from cmd arg} {
  global file_to_fix
  set fp [open $file_to_fix w]
  flush $fp
  close $fp
}
j
jedis

Post by jedis »

Did I place the putbot line in the proper place? It needs to be before the DCC send, I think.

The remote bot has the code, and I get no TCL errors, however, I still get 'File `quotes' already exists.' And it will not overwrite.

Bot sending the quote file (local):

Code: Select all

set backup_bot Bot1
set quote_backupfile "/path/to/quotes"

bind time - "41 00 * * *" dcc_quotebackup

proc dcc_quotebackup {x1 x2 x3 x4 x5} {
 global backup_bot quote_backupfile
  if [handonchan $backup_bot] {
   dccbroadcast "Backing up our beloved quote database! (RIP Quotey)"
    putbot $backup_bot "CLFILE"
    dccsend $quote_backupfile $backup_bot
  }
 return 0
}
Bot receiving the quote file (remote):

Code: Select all

set file_to_fix "$incoming-path/quotes"
bind bot - "CLFILE" clfile:remote
proc clfile:remote {from cmd arg} {
  global file_to_fix
  set fp [open $file_to_fix w]
  flush $fp
  close $fp
}
<font size=-1>[ This Message was edited by: jedis on 2002-01-05 00:50 ]</font>
W
Wcc
Master
Posts: 278
Joined: Sun Oct 28, 2001 8:00 pm
Location: USA
Contact:

Post by Wcc »

local bot:

Code: Select all

set backup_bot Bot1
set quote_backupdir "/path/to/"
set quote_backupfile "quotes"

bind time - "41 00 * * *" time:quotebackup
bind bot - DCCREADY bot:dccready

proc time:quotebackup {x1 x2 x3 x4 x5} {
 global backup_bot quote_backupfile
 dccbroadcast "Backing up our beloved quote database! (RIP Quotey)"
 putbot $backup_bot "CLFILE $quote_backupfile"
 return 0
}

proc bot:dccready {from cmd text} {
   global quote_backupdir quote_backupfile
   set botnick [lindex [split $text] 0]
   dccsend ${quote_backupdir}$quote_backupfile $botnick
   return 0
}
remote bot:

Code: Select all

bind bot - CLFILE bot:clfile

proc bot:clfile {from cmd text} {
  global botnick
  set file [lindex [split $text] 0]
  if {[file exists $file]} { file rename -force $file ${file}.bak }
  putbot $from "DCCREADY $botnick"
  return 0
}
c
ctaylor8

Post by ctaylor8 »

How do you call this backup script? What makes it run in the background (so to speak) and then do what it does at the specified time? Does is start up with your bot somehow? Thanks.
j
jedis

Post by jedis »

That script will not work as is, it was heavily modified after it was posted on the board. It doesn't function correctly as posted above.

You would need to load it via your config file, just as you would load any TCL for your bot.
Locked