egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

invalid command name? [solved]
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Sun Jul 18, 2010 4:27 pm    Post subject: invalid command name? [solved] Reply with quote

Ok folks, I've got this code snippet:

Code:
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:
#!/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:
/mnt/music/C/Collective Soul/Collective Soul - Better Now.mp3


The trouble is, the tcl script returns this:
Code:
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
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun Jul 18, 2010 4:49 pm    Post subject: Reply with quote

Perhaps by trying to execute the first line the search result as a tcl-command:
Code:
...
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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Sun Jul 18, 2010 7:25 pm    Post subject: Reply with quote

That fixed it, thanks!

Any idea why a dccsend $runcmd $nick times out almost immediately?
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun Jul 18, 2010 9:26 pm    Post subject: Reply with quote

DJCharlie wrote:
That fixed it, thanks!

Any idea why a dccsend $runcmd $nick times out almost immediately?


http://johoho.eggheads.org/eggdrop/other/faq1.html#sectc9
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Sun Jul 18, 2010 10:31 pm    Post subject: Reply with quote

Did that already. It finds the files just fine, but times out immediately, soon as dccsend is started.
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sun Jul 18, 2010 10:42 pm    Post subject: Reply with quote

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


Code:
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. Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Mon Jul 19, 2010 10:39 am    Post subject: Reply with quote

Added the code, rehashed, and tried again.

Code:
-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.
Back to top
View user's profile Send private message Visit poster's website
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Mon Jul 19, 2010 1:11 pm    Post subject: Reply with quote

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:
<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
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Jul 19, 2010 1:58 pm    Post subject: Reply with quote

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Mon Jul 19, 2010 2:05 pm    Post subject: Reply with quote

set xfer-timeout 90

How would I grab the request/notice? I'm running mIRC.
Back to top
View user's profile Send private message Visit poster's website
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Mon Jul 19, 2010 9:54 pm    Post subject: Reply with quote

Well, tried using XChat, and got this:

Code:
!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?
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Tue Jul 20, 2010 5:39 am    Post subject: Reply with quote

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.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Tue Jul 20, 2010 9:06 am    Post subject: Reply with quote

So how do I fix it? So far I've not found a single user who can get a file transfer to work.
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Jul 20, 2010 1:15 pm    Post subject: Reply with quote

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
DJCharlie
Voice


Joined: 06 May 2009
Posts: 37

PostPosted: Tue Jul 20, 2010 4:26 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber