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.

Another PISG Topic... :P

Old posts that have not been replied to for several years.
Locked
S
Stylez
Voice
Posts: 35
Joined: Fri Dec 06, 2002 1:32 am
Location: NS, Canada
Contact:

Another PISG Topic... :P

Post by Stylez »

Okay I'm making a script to run PISG from eggdrop... "USE CRONTAB DUMBASS" I know that's what you're all gonna say... lol, but I don't know the first thing about crontab, and how would I ftp it if I used crontab? Anyways, crontab isn't the subject... I have a very rough base for the script, basically a prototype, I will use 'bind time' in the finished script, but for now I'm using Timers. Anyhow here is what I have (lots of stuff is commented, messy, etc):

Code: Select all

#How often to update stats(in minutes)?
set interval "1"

set chan "#kc"
set pisgpath "/home/stylez/pisg/pisg"
set pisgtimer_trigger [timer $interval pisg:generate]
#bind time - "01 * * * *" pisg:generate
#bind time - "01 * * * *" pisg:ftp

proc pisg:generate {} {
global chan
global pisgpath
exec $pisgpath
set pisgtimer_ftp [timer 1 pisg:ftp]
puthelp "PRIVMSG $chan:IRC Stats Page Updating begun..."
#set pisgtimer_trigger [timer $interval update:pisg

}


proc pisg:ftp {} {
global chan
puthelp "PRIVMSG $chan:IRC Stats Page Updated, FTPing..."
if {[set er [sendftp /home/stylez/pisg/kc-stats.html ftp.kronicconcerz.com login pass /httpdocs/kc-stats.html]] != "1"} {
  putlog "Error in sendftp: $er"
  puthelp "PRIVMSG $chan:IRC Stats Page FTP Failed"
	}
else {puthelp "PRIVMSG $chan:"IRC Stats Page Update Successful."}
#putlog "IRC Stats Page Update Successful."
}
putlog "Pisg update loaded"

I realise it is incomplete... but the main concern is the exec part. When it execs the pisg perl script, it actually reads the output of it, such as:
<KronBot> Analyzing log(/home/stylez/eggdrop/mel/logs/kc.12.10.2002.log) in 'eggdrop' format...
<KronBot> Finished analyzing log, 1 days total.
<KronBot> Analyzing log(/home/stylez/eggdrop/mel/logs/kc.12.11.2002.log) in 'eggdrop' format...
It interprets this as an error and quits the script.
There is an argument for pisg, --silent, which wont output any of this, but I cant seem to execute it from the script, I get the No Such File Or Directory error.

Also have a basic question about timers.. When a timer goes through its cycle, then executes whatever command, what happens to it? Does it just stop a 0? Does it kill itself off? Or does it restart?
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

For simplicity.

Timers are like any other command.

Once executed, they terminate, until called again.

If I use the command "chattr" in a Tcl script, that is th end of it. Unless my script is called again, or some other script is called, to use the chattr command, then it will never be called.

If you need a timer to call again, then you have to issue the timer command again.

The most simple way to do this, is to call it within a timer called command.

EG

Code: Select all

proc test {} {
  timer 1 test
}
timer 1 test
Allthough very crude, it shows what needs to be done.

As for the "file not found" issue.

You didn't show an example of how you are trying to do it.

As noted on a post yesterday, the exec command takes things literaly.

Code: Select all

exec "/path/to/app --silent --socket --port 21"
exec /path/to/app --silent --socket --port 21
The 2 lines above, are totaly different, not just because of the quotes (though, these are creating the bigger differance).

In *nix, you can have spaces in filenames. To access these in a shell, you have to escape the space, for it to work.

In Tcl, using the exec command, you can save excaping by using quotes.

You should see now what is heppening, and a example of how to get around it/
S
Stylez
Voice
Posts: 35
Joined: Fri Dec 06, 2002 1:32 am
Location: NS, Canada
Contact:

Post by Stylez »

Ok I got it working, here is a snippet from the section I modified and how I did it:

Code: Select all

set pisgpath "/home/stylez/pisg/pisg"
set pisgtimer_trigger [timer $interval pisg:generate]
#bind time - "01 * * * *" pisg:generate
#bind time - "01 * * * *" pisg:ftp

proc pisg:generate {} {
global chan
global pisgpath
exec $pisgpath --silent
I also had to change the config for pisg because it said it couldn't find pageheader.txt (this worked fine when running from the shell), anyways I changed the entry from pageheader.txt to the full path to the pageheader.txt.

Ok now a question for bind time I want to clarify... as it is set right now in that snippet I posted, will it execute the command in it 01 minute past every hour, or every 01 minute? What are the different things I can do with the time formatting in this? tcl-commands.doc doesn't explain much about this. Thanks
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Past the hour, not every min.

The tiem bind operates, by generating a text string using a specific time format

IE: 03 13 02 12 02
EQ: 13:03pm 2nd December 2002

Using a mask, you can pick which time you want the code to trigger

What you may find, it's easier to call the code every min, and use some simple math in Tcl, to check if the time is right to trigger.

However, if are simply looing to execute once per hour, you may well use the mask "<min> *"
Locked