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.

2 scripting problems

Old posts that have not been replied to for several years.
Locked
L
LiquidZoo
Voice
Posts: 12
Joined: Thu Nov 11, 2004 12:59 am

2 scripting problems

Post by LiquidZoo »

I have 2 probably simple, but unbelievably annoying problems, each with a script I am trying to modify for my own needs.

First off, how do I execute a linux command (date -u) and store it inside a variable that I can later call in the middle of a block of text for a response? Say I wanted to call the variable gmtTime, and I want the block of text to be "The current time is $gmtTime (GMT)"

The second one appears to have a bracket out of place, but I can't for the life of me figure out where. Each time I remove a closing bracket (or brace, whatever you want to call them) it throws up a new error. Here is the relavent proc from the script:

Code: Select all

proc pub:nerf { nick uhost handle channel testes } {
set who [lindex [split $testes] 0]
global xmsg
set excuse [lindex $xmsg [rand [llength $xmsg]]]
if {[strlwr $message_chan]==[strlwr $chan]}{
if {$who == ""} {  
	putserv "NOTICE $nick :Usage: !nerf <nick>"  
	return 1  
}  
putserv "PRIVMSG $channel :\001ACTION [subst $excuse]\001"
}
}
putlog "NERF! Loaded"
Can anyone please help me out with these 2 issues?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Re: 2 scripting problems

Post by De Kus »

LiquidZoo wrote:First off, how do I execute a linux command (date -u) and store it inside a variable that I can later call in the middle of a block of text for a response? Say I wanted to call the variable gmtTime, and I want the block of text to be "The current time is $gmtTime (GMT)"
you can simply use 'set gmtTime [exec date -u]' for that. However, date -u returns the UTC time (GMT 0 time without daylight timeshift). If you prefer GMT 0 with posible daylight timeshift you should simply use 'set gmtTime [ctime [unixtime]]'.
if {[strlwr $message_chan]==[strlwr $chan]}{
you are getting "Tcl error: extra characters after close-brace" here, right?
you are missing the white space between the close and open brace at the end of the line.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
L
LiquidZoo
Voice
Posts: 12
Joined: Thu Nov 11, 2004 12:59 am

Re: 2 scripting problems

Post by LiquidZoo »

Thanks!

Aside from a couple of formatting errors I had in the rest of the script, they now work perfectly!
Locked