| View previous topic :: View next topic |
| Author |
Message |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Mon Apr 22, 2013 5:34 am Post subject: what am I doing wrong? |
|
|
| Code: | | {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: | % {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 |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Apr 22, 2013 6:15 am Post subject: |
|
|
if you wish to store the result of the exec command in the reply variable, then replace:
| Code: |
{exec cut \-d. \-f1 /proc/uptime} reply;
|
with either:
| Code: |
set reply [exec cut \-d. \-f1 /proc/uptime]
|
or:
| Code: |
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. |
|
| Back to top |
|
 |
spithash Master

Joined: 12 Jul 2007 Posts: 248 Location: Libera
|
Posted: Mon Apr 22, 2013 8:39 am Post subject: |
|
|
what about this?
| Code: | [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 |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Apr 23, 2013 12:27 am Post subject: |
|
|
Before the set secs you forgot to add an ;
Try with:
| Code: |
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. |
|
| Back to top |
|
 |
|