FTP scriptyness |
FTP scriptyness |
Oct 7 2008, 03:33 PM
Post
#1
|
|
Security and Projects Group: Clan Dogsbody Posts: 4,687 Thank(s): 1098 Points: 2,440 Joined: 31-August 07 From: A Magical Place, with toys in the million, all under one roof Member No.: 1 |
Firstly would it not be easier to script it so that a bunch of files are packaged - zipped or preferably tarred and then upload the one file then untar it on the remote server??
Something like the following run on "Remote server" => "computer where files are kept" (Dirty FTP connections*) On server, create a local ghey.zip and fills it from the FTP request. WebRequest.RegisterPrefix("ftp://", FtpWebRequest.Creator); WebRequest request = WebRequest.Create("ftp://ftp.magik5likesmen.com/ghey.tar.gz"); WebResponse response = request.GetResponse(); Stream stream = response.GetResponseStream(); Stream local = File.Create("ghey.tar.gz"); byte[] buffer = new byte[1024]; int n; do { n = stream.Read(buffer, 0, buffer.Length); local.Write(buffer, 0, n); } while (n > 0); stream.Close(); local.Close(); **then something like.. (I can't remember the syntax )*** gz.UnTarGz("ghey.tar.gz", untarRoot, bNoAbsolute); Obviously this can be rejigged if you want to run as a script on the "computer where files are kept" > "Remote Server" type direction *I do it this way so that a remote secure server never accepts inbound FTP connections, it should always initiate outbound connections by script. This means that the script can run with limited permissions e.g. run under a user to reach the outside world and place files in a given limited directory with no permissions outside of that directory. A separate script with permissions to this directory but no permissions to the outside world can then be run to unpack and palce the files where they belong; this is purely limiting security. -------------------- |
|
|
Oct 8 2008, 10:10 AM
Post
#2
|
|
Security and Projects Group: Clan Dogsbody Posts: 4,687 Thank(s): 1098 Points: 2,440 Joined: 31-August 07 From: A Magical Place, with toys in the million, all under one roof Member No.: 1 |
Code that I routinely steal err.. I mean utilise for zipping in #:
http://www.vwd-cms.com/Forum/Forums.aspx?topic=18 App hanging... ahh the old blocking problem... good old 'asynchronous sockets' to the rescue - basically you should be able to handle GUI and networking in 1 thread Quickly googled: http://tinyurl.com/4jyfyt -------------------- |
|
|
Lo-Fi Version | Time is now: 24th November 2024 - 11:29 AM |