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.

Problem with sendftp.tcl

Help for those learning Tcl or writing their own scripts.
Post Reply
N
Nara
Halfop
Posts: 40
Joined: Sun Jul 23, 2006 11:12 pm

Problem with sendftp.tcl

Post by Nara »

I am using the sendftp protocol and I get this error whenever I use it:

Code: Select all

[21:36:44] <egln|radiobot> Currently: ftp: bind: Address already in use
[21:36:44] <egln|radiobot> Currently:     while executing
[21:36:44] <egln|radiobot> Currently: "close $pipe"
[21:36:44] <egln|radiobot> Currently:     (procedure "sendftp" line 28)
[21:36:44] <egln|radiobot> Currently:     invoked from within
[21:36:44] <egln|radiobot> Currently: "sendftp /home/century0/hrpeggdrop/djonair.txt [censored] [censored] [censored] /reports/djonair.txt"
[21:36:44] <egln|radiobot> Currently:     (procedure "battle:update" line 2)
[21:36:44] <egln|radiobot> Currently:     invoked from within
[21:36:44] <egln|radiobot> Currently: "battle:update $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"
Does anyone know a way to fix this problem?

~Nara
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

There is no "sendftp" protocol in TCL.
You most likely will not get help without posting the script.
N
Nara
Halfop
Posts: 40
Joined: Sun Jul 23, 2006 11:12 pm

Post by Nara »

Here is the script:

Code: Select all

#
# Sendftp v1.01 (12/6/97) by Ernst <ernst@studbox.uni-stuttgart.de>
# Ernst's eggdrop page:  http://www.sodre.net/ernst/eggdrop/
# =============================================================================

# This is a proc to send a file via FTP to another server. Useful in many
# situations, for example to upload a HTML file generated by eggdrop to your
# www server if it is not the same as your eggdrops machine.

# Change this to something to use to check if a host is alife.
# set pingcheck "" to disable this checking.
# "/bin/ping -c 1" works on Linux. Try just "/bin/ping" on other machines
# Set to "" to disable this checking
set pingcheck ""

# Include it with 'source scripts/sendftp.tcl'.  Call it with all parameters:
#
#   sendftp <localfile> <server> <user> <password> <remotefile>
#
# 'localfile' and 'remotefile' *must* both be given as FULL paths to the
# filenames, the first on the local, the second	on the remote server.
#
# For example:
#
# sendftp /home/bill/stats.htm www.ms.com bill secret /bgates/WWW/stats.htm
#             (local-file       server    user  pass       remote-file)

proc sendftp { localfile server user pass remotefile } {
	global pingcheck
	if {![file exist $localfile]} {
		return "sendftp: File $localfile does not exist."
	}
	if {$pingcheck != ""} {
		if {[catch {exec [lindex $pingcheck 0] [lrange $pingcheck 1 end] $server > /dev/null 2> /dev/null}]} {
			return "sendftp: Machine $server seems to be dead."
		}
	}
	set noftp [catch {set ftpprog [exec which ftp]}] 
	if {$noftp} {
		if {[file executable /usr/bin/ftp]} {
			set ftpprog /usr/bin/ftp
			set noftp 0
		}
		if {[file executable /bin/ftp]} {
			set ftpprog /bin/ftp
			set noftp 0
		}
	}
	if {$noftp} { return "sendftp: You don't seem to have the 'ftp' tool" }
	set pipe [open "|$ftpprog -n $server" w]
	puts $pipe "user $user $pass"
	puts $pipe "bin"
	puts $pipe "put $localfile $remotefile"
	puts $pipe "quit"
	close $pipe
	return 1
}


User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

Your problem is with the battle:update procedure.
You should have posted the script with battle:update in it.
The error was quite clear where the problem is:
procedure "battle:update" line 2
N
Nara
Halfop
Posts: 40
Joined: Sun Jul 23, 2006 11:12 pm

Post by Nara »

DragnLord wrote:Your problem is with the battle:update procedure.
You should have posted the script with battle:update in it.
The error was quite clear where the problem is:
procedure "battle:update" line 2
Here's the code for that:

Code: Select all

bind pub M @update battle:update

proc battle:update { nick host hand chan text } {
	sendftp /home/century0/hrpeggdrop/djonair.txt [censored personal info] /reports/djonair.txt
	putlog "Updated logs on website."
	putquick "NOTICE $nick :$head Updated logs on website. $tail"
}
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Actually, the error is'nt with either tcl's, but with the ftp-binary the sendftp script relies on...
The ftp-binary is unable to create a listening-socket, and thus exits with the error message "ftp: bind: Address already in use".

One way of possibly solving this issue would be to make the client run in passive mode, using proper command with the client. But other than that, your best chance of getting this solved would be to bug your sysadmin.
NML_375
N
Nara
Halfop
Posts: 40
Joined: Sun Jul 23, 2006 11:12 pm

Post by Nara »

I am the sysadmin. I just simply have a very limited linux knowledge. Could you tell me what needs to be done?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

This would unfortunately be depending on what system and/or ftp client software you've got installed.
Some psuedo-standard approach would be to give the "sendport" command to the client to disable non-passive ("PORT") mode.

To do this, change this:

Code: Select all

   set pipe [open "|$ftpprog -n $server" w]
   puts $pipe "user $user $pass"
   puts $pipe "bin"
   puts $pipe "put $localfile $remotefile"
   puts $pipe "quit"
into this:

Code: Select all

   set pipe [open "|$ftpprog -n $server" w]
   puts $pipe "user $user $pass"
   puts $pipe "bin"
   puts $pipe "sendmode"
   puts $pipe "put $localfile $remotefile"
   puts $pipe "quit"
You might however wish to look into your system's setup, as users should normally be able to bind to non-system (above 1023) ports on all interfaces. Also, all but very antique ftp software would use random non-system ports for PORT-transfers.
NML_375
N
Nara
Halfop
Posts: 40
Joined: Sun Jul 23, 2006 11:12 pm

Post by Nara »

I use the base FTP program. If it would assist you, I can give you a root account on my box temporarily and you can check whether or not that's the problem. I'll also check the sendmode and get back to you.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Giving root-access to someone you don't know in person and really, really trust is a very bad idea.

That said, back to the problem:
Which system do you run, and where applicable, which distribution?
Try executing /usr/bin/ftp, or if command not found, /bin/ftp; connect to remote site, logon with the same credentials that you use with your script, and manually try to send the file. See if you get the same error, and wether using the command "sendport" within the ftp-client helps.

Edit:
Your system does'nt happen to be behind a masquerading firewall (NAT)?
NML_375
N
Nara
Halfop
Posts: 40
Joined: Sun Jul 23, 2006 11:12 pm

Post by Nara »

It's behind a firewall, but FTP ports are open. I use a Slackware based distro named Zenwalk. I don't get the error when I manually do it. I have yet to find time to put in sendmode and test it that way.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

[21:36:44] <egln|radiobot> Currently: ftp: bind: Address already in use


Looks like there's more than one process using that address.. If it was not able to bind the port for permissions reasons, it would've given a different error msg.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

@Nara: Then switching to passive will most certainly solve your issues. This is because your client will send both ip-address and port-number to where the server should connect the datachannel. Unfortunately, your client only knows of its local (or LAN) ip and not the "external" (or WAN), and sends this. Obviously, since the server is'nt located behind your firewall, this really does'nt make much sense to the server, giving a "500 Invalid PORT command" response-code. Your ftp-client then returns a somewhat misleading error message, stating that the address is already in use..

In this case it has nothing to do with any other processes running on your shell
NML_375
Post Reply