From: JonoK on
Hi,

I'm trying to get a script that ftps files to handle the destination
being down more gracefully than it does at the moment, but I'm
obviously missing something ... The environment is WinTcl 8.5.6 on a
Windows 2003 Server.

Doesn't catch get any errors in the command it's executing ... or is
the ftp not actually creating an error, despite the output.

I can see the Open doesn't work, as the session == -1, but how do I
stop the ftp package from vomiting the error output?

TIA.
Jonathan.

in the script below ...
-------------
#!tclsh85
package require ftp

set host "1.2.3.4"
if {[catch {set session [ftp::Open $::host user password ]} errmsg]} {
log "Huh ... bad connect - $errmsg"
}
puts "session is $session"
-------------

I get the output ...
----------
D:\Apps\tcl>d:\Apps\WinTclTk\bin\tclsh85.exe t.tcl
error error | E: Service not available!:
error can't read "ftp(DummySock)": no such element in array
error while executing
error "close $ftp(DummySock)"
error error | E: Not connected!:
error can't read "ftp(DummySock)": no such element in array
error while executing
error "close $ftp(DummySock)"
session is -1
----------
From: Robert Heller on
At Tue, 2 Mar 2010 15:16:11 -0800 (PST) JonoK <jonkelly(a)fastmail.fm> wrote:

>
> Hi,
>
> I'm trying to get a script that ftps files to handle the destination
> being down more gracefully than it does at the moment, but I'm
> obviously missing something ... The environment is WinTcl 8.5.6 on a
> Windows 2003 Server.
>
> Doesn't catch get any errors in the command it's executing ... or is
> the ftp not actually creating an error, despite the output.
>
> I can see the Open doesn't work, as the session == -1, but how do I
> stop the ftp package from vomiting the error output?
>
> TIA.
> Jonathan.
>
> in the script below ...
> -------------
> #!tclsh85
> package require ftp
>
> set host "1.2.3.4"
> if {[catch {set session [ftp::Open $::host user password ]} errmsg]} {

Try this:

if {[catch {ftp::Open $::host user password} session]} {
log "Huh ... bad connect - $session"
} else {
....
}

> log "Huh ... bad connect - $errmsg"
> }
> puts "session is $session"
> -------------
>
> I get the output ...
> ----------
> D:\Apps\tcl>d:\Apps\WinTclTk\bin\tclsh85.exe t.tcl
> error error | E: Service not available!:
> error can't read "ftp(DummySock)": no such element in array
> error while executing
> error "close $ftp(DummySock)"
> error error | E: Not connected!:
> error can't read "ftp(DummySock)": no such element in array
> error while executing
> error "close $ftp(DummySock)"
> session is -1
> ----------
>

--
Robert Heller -- Get the Deepwoods Software FireFox Toolbar!
Deepwoods Software -- Linux Installation and Administration
http://www.deepsoft.com/ -- Web Hosting, with CGI and Database
heller(a)deepsoft.com -- Contract Programming: C/C++, Tcl/Tk


From: JonoK on
On Mar 3, 11:30 am, Robert Heller <hel...(a)deepsoft.com> wrote:
> At Tue, 2 Mar 2010 15:16:11 -0800 (PST) JonoK <jonke...(a)fastmail.fm> wrote:
>
>
>
>
>
> > Hi,
>
> > I'm trying to get a script that ftps files to handle the destination
> > being down more gracefully than it does at the moment, but I'm
> > obviously missing something ... The environment is WinTcl 8.5.6 on a
> > Windows 2003 Server.
>
> > Doesn't catch get any errors in the command it's executing ... or is
> > the ftp not actually creating an error, despite the output.
>
> > I can see the Open doesn't work, as the session == -1, but how do I
> > stop the ftp package from vomiting the error output?
>
> > TIA.
> > Jonathan.
>
> >  in the script below ...
> > -------------
> > #!tclsh85
> > package require ftp
>
> > set host "1.2.3.4"
> > if {[catch {set session [ftp::Open $::host user password ]} errmsg]} {
>
> Try this:
>
> if {[catch {ftp::Open $::host user password} session]} {
>      log "Huh ... bad connect - $session"
>

Thanks. I learnt something about catch ... if there is no error the
result is captured in the resultVarName variable.

I tried that, and interestingly, it appears ftp isn't throwing an
error ... the output from your suggestion is
--script--
#!tclsh85
package require ftp

set host "1.2.3.4"
if {[catch {ftp::Open $::host user password} session]} {
puts "Huh ... bad connect - $session"
}
--output--
error error | E: Service not available!:
error can't read "ftp(DummySock)": no such element in array
error while executing
error "close $ftp(DummySock)"
error error | E: Not connected!:
error can't read "ftp(DummySock)": no such element in array
error while executing
error "close $ftp(DummySock)"
---
From: Donal K. Fellows on
On 2 Mar, 23:16, JonoK <jonke...(a)fastmail.fm> wrote:
> I can see the Open doesn't work, as the session == -1, but how do I
> stop the ftp package from vomiting the error output?

They're being reported by the tcllib log package, as the ftp package
documents in:
http://tcllib.sourceforge.net/doc/ftp.html

Now, by reading the log package documentation at:
http://tcllib.sourceforge.net/doc/log.html
(there's a pattern there ;-)) we see that we can suppress error
messages with the right incantation:

::log::lvSuppressLE error

Note that when I try testing things, I don't get so many messages from
the ftp package on a trivial failed connect anyway. You might want to
try updating to get something less chatty too (I've got version 2.4.9
FYI).

Donal.