Why Does My File Change From Read-Only Mode To Non-Read-Only Mode, When I FTP It?
I am trying to ftp a file using TCL. The file is in a readonly mode in my source directory. but after i do a ftp, the file changes to non readonly mode (something i do not want .. i still want the file to be readonly).. i am using dos ftp .. any pointers will be aqppreciated. Ashish
March 3rd: It sounds like that's a bug in the ftp package. Whether this is the correct/best solution, I'm not sure, but you could cache the readonly value and reset it later with something like...
set ro [file attributes $filename -readonly] <insert FTP code here> file attributes $filename -readonly $ro
2004/10/26 - e0richt
I don't believe that FTP is supposed to preserve file modes. I had a similar problem working on a RS/6000 box. You will either have to set the file attributes after transfer or if you had a lot of files you could ftp a .tar file which will preserve file attributes when it is unrolled.
Is there any command we can send an FTP server and have it tell us whether it supports resuming?
According to RFC 959 [L1 ] you can use FTP command 'REST'. Not every FTP server implements this command!
MG I don't know whether this is a solution that would work everywhere, but when I do
package require ftp set handle [ftp::Open $server $user $pw] set code [lindex [::ftp::Quote $handle REST] 0]
on my FTP server, code is set to 501 (the ::ftp::Quote command returning '501 No restart point'), whereas
set code [lindex [::ftp::Quote $handle JIBBERISH] 0]
sets code to 500 (Unknown command).
Is there any Tcl-only method to check whether I have an Internet connection active at the moment?
You can try to open a connection to a well known server. For instance: www.google.com port 80.
LES That does not solve my problem, I'm afraid. I don't like the idea of having to rely on a single site. It could be down at any one time and cause an incorrect result. The more sites I use, the more reliable the method will be, but so much slower as well. And I might want to poll the system with a fairly high frequency. It would have to be some way to poll the system directly. PowerPro does that very well and easily, but it runs on Windows only.
Lars H: One point to bear in mind is that it isn't altogether clear what it means to have "an Internet connection". People who are sitting on some intranet may have a perfectly good connection to that (in which case the system probably would think that there is "an Internet connection"), but the link from intranet to Internet may be down. How would you like that situation to be handled?
ECS: You have the option to keep the connection open. It will be closed by timeout (when the server closes it) or the connection died. This way you don't have to open lots of connections to know if you have an Internet connection.
If you can use UDP you can probe pool.ntp.org (a random time server on the Internet) on port 123 or even one of the DNS root servers (port 53).
As Lars pointed out, it doesn't make sense to query the system, it ist possible to be "connected" without actually having any connectivity. I would recommend to check against a list of hosts, and to stop checking as soon as one of the hosts replies. If you choose a reliable host for the top of the list, it will not be slower than only querying one, and if that first host fails, you have a reliable result because of the other hosts in the list.
HJG Depending on the configuration, sending packets to other machines might cause an inactive connection to go up. That could be undesirable, e.g. when using dial-up. To query the system, you could call some utility, such as ifconfig on linux / ipconfig on windows, or even read the packet-counter directly from the network-interface. But, even an active network-connection does not mean that you can reach your intended target - there might be firewalls or other things in the way...