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.

exec in backround/with callback possible?

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

exec in backround/with callback possible?

Post by sKy »

Hey

I want a eggdrop to start a external application. Exec wait`s until the prozess ends and will block anything else. Thats what i want to prevent. Is there a way to start a process and to get a callback after it?

best regards
sKy
socketapi | Code less, create more.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

You can use

Code: Select all

open "|<command>"
instead, which is supposed to do the same without waiting like exec does.

A forum search on the topic will result in great information about it. Also, you can take a look at bgexec.tcl by strikelight which does what you want.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

search for "tail -f"
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

My failure, i forgot to add thats about windrop.

exec and open |
will always return an error like:
Tcl error: couldn't create error file for command: no such file or directory

Is it possible to fix that?

EDIT:
BgExec ( http://wiki.tcl.tk/12704 ) won`t work too, cause the mainproc is going to use open | aswell too.

Is there any way to execute something (windrop)?
socketapi | Code less, create more.
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

anyone?
socketapi | Code less, create more.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

You'll need to find the appropriate ported Unix tools to use with Windrop or install cygwin and compile them yourself. The tool(s) are then copied into your Windrop main folder.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

what's the Tcl version?

this thing looks pretty ancient to me
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

i got it from here
http://windrop.sourceforge.net/downloads.html

before i got Eggdrop v1.6.17 Handlen32 (08.07.2005)

and now i`ve updated to Eggdrop v1.6.18+spelling-errors-suck Handlen32 (25.12.2005)
info tclversion 8.4
info patchlevel 8.4.12

the error still comes up.
it`s not cause i use handlen32 version? (i doub`t that this has anything to do with it)

btw: what means "spelling-errors-suck"?
socketapi | Code less, create more.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

check your temp-path and if you have c:\tmp; also check the FAQ at windrop's website

or wait for DeKus, he's our windrop guru; I personally have never used the thing, Windows is desktop OS to me
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

The temp path is correct (otherwise the bot won`t start).

--

from here: http://wiki.tcl.tk/12704 (is working anyway, eggdrop just doesn`t have the command auto_execok)

Code: Select all

set redir [expr {[info patchlevel] >= "8.4.7"?{2>@1}:{2>@stdout}}]
if [catch {open "| $prog $redir" r} pH] {
i wonder that i can open and execute something on that way. but i don`t really understand why. could someone explain what these changes do?
2>@1
2>@stdout
socketapi | Code less, create more.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

you can savely delete them for your script. > changes the default output (stdout) which is usually the console (which you read from with gets/read). example from tclsh console:

Code: Select all

~$ tclsh
% open "| uname" r
file3
% read file3
Linux

% close file3
%
I hope you will understand now better how it works. Don't forget to use fileevent for true asyncronous acces (this above is syncron, too).
So dont forget to save the return value of open, because you will need it to read from :).
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...
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

Thank you, but i know how open | and exec work. =) My code works already on unix/eggdrop system without problems.

My tests:

- with unix: eggdrop 1.6.17 - working fine
channelid`s like file3

- with unix: tclsh - working fine
channelid`s like file3

- with windows xp: windrop 1.6.17 - Tcl error: couldn't create error file for command: no such file or directory

- with windows xp: 1.6.18cvs - Tcl error: couldn't create error file for command: no such file or directory

- with windows xp: 1.6.16 - working fine
(but this version is outdated, i don`t really want to use it)
the channelid`s are like file107e0560

the incomprehensible was that this (from bgExec):
set redir [expr {[info patchlevel] >= "8.4.7"?{2>@1}:{2>@stdout}}]
if [catch {open "| $prog $redir" r} pH] {
will work with windrop 1.6.17 and 1.6.18cvs [but for read acess mode r only :/].

I think the problem is about the windrop/cygwin/tcl version? Is there another solution then using windrop 1.6.16?

DeKus: May I pm you on irc?
socketapi | Code less, create more.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

report the bug to windrop dev folks, we can't help you any further
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
Post Reply