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.

invalid command name? [solved]

Help for those learning Tcl or writing their own scripts.
D
DJCharlie
Voice
Posts: 37
Joined: Wed May 06, 2009 10:45 am
Contact:

invalid command name? [solved]

Post by DJCharlie »

Ok folks, I've got this code snippet:

Code: Select all

proc pub_get {nick host hand chan text} {
   putserv "NOTICE $nick :Searching for $text. Please stand by..."
   set runcmd [exec /usr/local/filebot/search.sh "$text"]
   if {[catch $runcmd res]} {
      putserv "NOTICE $nick:No matches for $text"
   }
   putserv "NOTICE $nick :$res"
   putlog "$res"
}
Which is running this shell script:

Code: Select all

#!/bin/bash

srch="$1"
oput1="/usr/local/filebot/tmp/search$$.lst"

find /mnt/music -name "*$srch*.mp3" > $oput1

fil=`head -1 $oput1`

echo "$fil"

rm -f $oput1
exit
Sample output of the shell script (command line option of "Better Now"):

Code: Select all

/mnt/music/C/Collective Soul/Collective Soul - Better Now.mp3
The trouble is, the tcl script returns this:

Code: Select all

invalid command name "/mnt/music/C/Collective"
Where am I going wrong?
Last edited by DJCharlie on Wed Jul 21, 2010 8:59 pm, edited 1 time in total.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Perhaps by trying to execute the first line the search result as a tcl-command:

Code: Select all

...
if {[catch $runcmd res]} {
...
This executes the content of runcmd as a tcl-command, and stores the return-code, or error message in the case of an error, into the variable res. The return-code of catch itself reflects whether it caught an tcl-error or not.

Next, runcmd contains the result of calling the external shellscript - that is, whatever the shellscript echo:ed to stdout. In this case, "/mnt/music/C/Collective Soul/Collective Soul - Better Now.mp3".

So, most likely, you don't wan't to use the catch command.

On a side-note, I'd personally use the glob command for file searching, rather than invoking an external bash script.
NML_375
D
DJCharlie
Voice
Posts: 37
Joined: Wed May 06, 2009 10:45 am
Contact:

Post by DJCharlie »

That fixed it, thanks!

Any idea why a dccsend $runcmd $nick times out almost immediately?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

DJCharlie wrote:That fixed it, thanks!

Any idea why a dccsend $runcmd $nick times out almost immediately?
http://johoho.eggheads.org/eggdrop/othe ... tml#sectc9
D
DJCharlie
Voice
Posts: 37
Joined: Wed May 06, 2009 10:45 am
Contact:

Post by DJCharlie »

Did that already. It finds the files just fine, but times out immediately, soon as dccsend is started.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

DJCharlie wrote:Did that already. It finds the files just fine, but times out immediately, soon as dccsend is started.

Code: Select all

catch { set result [dccsend $runcmd $nick] } error
if {![info exists result]} {
  putserv "NOTICE $nick: Error: $error"
} else {
  set indexlist [list "success" "the dcc table is full (too many connections)" "can't open a socket for the transfer" "the file doesn't exist" "the file was queued for later transfer, which means that person has too many file transfers going right now" "copy-to-tmp is enabled and the file already exists in the temp directory"]
  putserv "NOTICE $nick: [string totitle [lindex $indexlist $result]]"
}
Use the above code in place of merely using: dccsend $runcmd $nick

Report back what the above code replies. ;)
D
DJCharlie
Voice
Posts: 37
Joined: Wed May 06, 2009 10:45 am
Contact:

Post by DJCharlie »

Added the code, rehashed, and tried again.

Code: Select all

-FredGibson- Searching for Better Now. Please stand by...
-FredGibson- Sending you /mnt/music/C/Collective Soul/Collective Soul - Better Now.mp3
-FredGibson- Timeout during transfer, aborting Collective_Soul_-_Better_Now.mp3.
That pops up immediately after.
D
DJCharlie
Voice
Posts: 37
Joined: Wed May 06, 2009 10:45 am
Contact:

Post by DJCharlie »

Update: We can rule out firewalling. Ports are open on the firewall for this range (4500 - 4550).

Here's the results of a .dccstat:

Code: Select all

<FredGibson> [13:09] #DJCharlie# dccstat
<FredGibson> SOCK ADDR     PORT  NICK      HOST              TYPE
<FredGibson> ---- -------- ----- --------- ----------------- ----
<FredGibson> 7    7F000101  3393 (telnet)  *                 lstn  3393
<FredGibson> 8    00000000     0 (dns)                       dns   (ready)
<FredGibson> 11   4020146E  6667 (server)  chat.kjsr.net     serv  (lag: 0)
<FredGibson> 14   C0A8000B  1026 DJCharlie JCharlie@kjsr.net chat  flags: cPtEp/0
<FredGibson> 15   DEADF00D  4500 DJKyo     irc               send  waited 65s
<FredGibson>     Filename: Amy_Castle_-_Cuppycake_Song.mp3
<FredGibson> 17   DEADF00D  4501 DJCharlie irc               send  waited 38s
<FredGibson>     Filename: Collective_Soul_-_Better_Now.mp3
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Could you check the value of xfer-timeout?
Also, see if you can grap the DCC SEND ctcp request/notice from your irc client, and validate that the correct IP is sent in the request.
NML_375
D
DJCharlie
Voice
Posts: 37
Joined: Wed May 06, 2009 10:45 am
Contact:

Post by DJCharlie »

set xfer-timeout 90

How would I grab the request/notice? I'm running mIRC.
D
DJCharlie
Voice
Posts: 37
Joined: Wed May 06, 2009 10:45 am
Contact:

Post by DJCharlie »

Well, tried using XChat, and got this:

Code: Select all

!fetch Collective Soul - Better Now
-FredGibson- Searching for Collective Soul - Better Now. Please stand by...
-FredGibson- Sending you /mnt/music/C/Collective Soul/Collective Soul - Better Now.mp3
* FredGibson has offered Collective_Soul_-_Better_Now.mp3 (3115136 bytes)
* DCC RECV connect attempt to FredGibson failed (err=Connection refused)
Does that help any?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

DJCharlie wrote:* DCC RECV connect attempt to FredGibson failed (err=Connection refused)

Does that help any?
Your refusing the send. Most IRC clients won't auto-accept and they certainly won't come preset to auto-accept *.mp3. So the problem isn't your bot at all, although the code I gave you will indicate to users when it is your bots fault. The problem is entirely the receiving clients fault.
D
DJCharlie
Voice
Posts: 37
Joined: Wed May 06, 2009 10:45 am
Contact:

Post by DJCharlie »

So how do I fix it? So far I've not found a single user who can get a file transfer to work.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Speechles,
Think again. The error rather suggests that the irc client was unable to connect to the eggdrop. This usually suggests that the eggdrop sends the incorrect IP address with the DCC SEND request - running the eggdrop behind a masquerading router/firewall and not setting the nat-ip setting properly often causes this.
NML_375
D
DJCharlie
Voice
Posts: 37
Joined: Wed May 06, 2009 10:45 am
Contact:

Post by DJCharlie »

As far as I know, the router isn't masquerading. How can I find out what IP the eggdrop is claiming?

The server it's on DOES have a domain name (provided by dyndns) if that helps.
Post Reply