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.

what am I doing wrong?

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

what am I doing wrong?

Post by spithash »

Code: Select all

{exec cut \-d. \-f1 /proc/uptime} reply; set secs [expr $reply % 60]; set mins [expr $reply / 60 % 60]; set hours [expr $reply / 3600 % 24]; set days [expr $reply / 86400]
Can anyone please let me know how can I fix this? what am I doing wrong?
I'm not a coder, I'm trying to be one. this is from a script I found and I am trying to fix it.

The errors I get are:

Code: Select all

% {exec cut \-d. \-f1 /proc/uptime} reply; set secs [expr $reply % 60]; set mins [expr $reply / 60 % 60]; set hours [expr $reply / 3600 % 24]; set days [expr $reply / 86400]
invalid command name "exec cut \-d. \-f1 /proc/uptime"
%
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

if you wish to store the result of the exec command in the reply variable, then replace:

Code: Select all

{exec cut \-d. \-f1 /proc/uptime} reply;
with either:

Code: Select all

set reply [exec cut \-d. \-f1 /proc/uptime]
or:

Code: Select all

catch {exec cut \-d. \-f1 /proc/uptime} reply
I would go with first option.
Once the game is over, the king and the pawn go back in the same box.
User avatar
spithash
Master
Posts: 249
Joined: Thu Jul 12, 2007 9:21 am
Location: Libera
Contact:

Post by spithash »

what about this?

Code: Select all

[03:59:38] <@spithash> ;set reply {exec cut -d. -f1 /proc/uptime} set secs [expr {$reply % 60}]; set mins [expr {$reply / 60 % 60}]; set hours [expr {$reply / 3600 % 24}]; set days [expr {$reply / 86400}]
[03:59:40] <@nigger> spithash: #29 Tcl error: can't use non-numeric string as operand of "%"
Libera ##rtlsdr & ##re - Nick: spithash
Click here for troll.tcl
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Before the set secs you forgot to add an ;

Try with:

Code: Select all

set reply [exec cut -d. -f1 /proc/uptime]; set secs [expr {$reply % 60}]; set mins [expr {$reply / 60 % 60}]; set hours [expr {$reply / 3600 % 24}]; set days [expr {$reply / 86400}]
Once the game is over, the king and the pawn go back in the same box.
Post Reply