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 7 2008, 04:13 PM
Post
#2
|
|
Paddle Master Group: Clan Members Posts: 2,085 Thank(s): 30 Points: 317 Joined: 3-December 07 Member No.: 50 |
yeh good idea actually, never thought of packaging up
had a quick check and php (yes php not asp ) supports zips over tars so ill use them instead. basically theres a php script that executes after each upload to enter each file into a mysql db ive created so ill get php to do the unzipping as well =] cheers for the help =] -------------------- |
|
|
Oct 8 2008, 08:28 AM
Post
#3
|
|
Paddle Master Group: Clan Members Posts: 2,085 Thank(s): 30 Points: 317 Joined: 3-December 07 Member No.: 50 |
nice idea on the security thing as well, but the only people using this will be staff uploading to our server so security shouldn't really be an issue.
i had a little dig around google as it seems c# only supports zipping one file at a time, where as i need to zip (sometimes multiple folders) containing multiple files into one zip. the ftp app works just fine as is, albeit a few annoying 550's every so often, and ive got the rest of the php stuff to be getting on with so if theres a quick simple solution for this then great, if not its not really an issue =] oh one more thing - on the first connection it makes, the app seems to hang until connection is made, short of going down the threading route, do you no of a quick fix for this? cheers -------------------- |
|
|
Oct 8 2008, 10:10 AM
Post
#4
|
|
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 -------------------- |
|
|
Oct 8 2008, 12:12 PM
Post
#5
|
|
Paddle Master Group: Clan Members Posts: 2,085 Thank(s): 30 Points: 317 Joined: 3-December 07 Member No.: 50 |
cheers for the links,
will look into the sockets thing if i have time near the end of the deadline as itll take me awhile to get my head round. the zip script seems quite simple, yet kind of a hack when microsoft could have made it so much easier... ta -------------------- |
|
|
Oct 8 2008, 12:30 PM
Post
#6
|
|
Knight Lieutenant Group: Clan Members Posts: 824 Thank(s): 0 Points: 218 Joined: 30-December 07 From: Brighton Member No.: 54 |
Total jiberish
-------------------- There are 10 types of people in this world, those who understand binary and those who don't |
|
|
Oct 8 2008, 12:39 PM
Post
#7
|
|
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 |
Well thats how I feel when I see a thread about motorbikes
-------------------- |
|
|
Oct 8 2008, 12:41 PM
Post
#8
|
|
Knight Lieutenant Group: Clan Members Posts: 989 Thank(s): 1 Points: 215 Joined: 5-June 08 From: Tyler, Texas, US Member No.: 124 |
i don't understand most of that!!! i must need more classes!!! of course i haven't done anything with c# yet.
-------------------- |
|
|
Oct 8 2008, 12:41 PM
Post
#9
|
|
Paddle Master Group: Clan Members Posts: 2,085 Thank(s): 30 Points: 317 Joined: 3-December 07 Member No.: 50 |
before i started this i was like ZOHNOES! my first app in c#!
but then 475 lines later i feel ive done a good job =] but then again having "jnr developer"as my job title gets me off the hook when i end up googling everything i dont know =] pretty comfortable with programming now though, as in syntax, writing custom classes etc i prefer as3 though, just not the authoring environment as the available code hinting is shite -------------------- |
|
|
Oct 8 2008, 01:01 PM
Post
#10
|
|
Paddle Master Group: Clan Members Posts: 2,085 Thank(s): 30 Points: 317 Joined: 3-December 07 Member No.: 50 |
but i still dont like regular expressions :s
-------------------- |
|
|
Oct 8 2008, 01:10 PM
Post
#11
|
|
Knight Lieutenant Group: Clan Members Posts: 989 Thank(s): 1 Points: 215 Joined: 5-June 08 From: Tyler, Texas, US Member No.: 124 |
i'm startin to get it down. writin small programs is fairly simple to me, but i have trouble with the bigger ones. its mainly the paper work the teacher makes us do that slows me down. i figure by the time i write all the IPO charts and crap, i could have already wrote the dam program!!!
-------------------- |
|
|
Oct 8 2008, 01:25 PM
Post
#12
|
|
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 |
[Warning: bad c# regex joke follows]
What regular expression can be found in December? Answer: [^L] -------------------- |
|
|
Oct 8 2008, 02:12 PM
Post
#13
|
|
Knight Lieutenant Group: Clan Members Posts: 989 Thank(s): 1 Points: 215 Joined: 5-June 08 From: Tyler, Texas, US Member No.: 124 |
i can't figure it out! whats the answer? lol.
-------------------- |
|
|
Oct 8 2008, 02:48 PM
Post
#14
|
|
Paddle Master Group: Clan Members Posts: 2,085 Thank(s): 30 Points: 317 Joined: 3-December 07 Member No.: 50 |
any character not equal to L... eh
-------------------- |
|
|
Oct 8 2008, 02:57 PM
Post
#15
|
|
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 |
Sorry... I'll get my coat -------------------- |
|
|
Oct 8 2008, 03:23 PM
Post
#16
|
|
Paddle Master Group: Clan Members Posts: 2,085 Thank(s): 30 Points: 317 Joined: 3-December 07 Member No.: 50 |
to be fair i did laugh
for a few seconds -------------------- |
|
|
Oct 8 2008, 05:02 PM
Post
#17
|
|
Knight Lieutenant Group: Clan Members Posts: 989 Thank(s): 1 Points: 215 Joined: 5-June 08 From: Tyler, Texas, US Member No.: 124 |
i had myself a laugh too!
-------------------- |
|
|
Oct 8 2008, 06:53 PM
Post
#18
|
|
Knight Errant Group: Clan Members Posts: 645 Thank(s): 0 Points: 79 Joined: 18-November 07 From: Swindon Member No.: 43 |
GCSE IT = name sum input devices, make a stupid database using acess for no good reason
Law x -------------------- |
|
|
Oct 8 2008, 07:10 PM
Post
#19
|
|
Paddle Master Group: Clan Members Posts: 2,085 Thank(s): 30 Points: 317 Joined: 3-December 07 Member No.: 50 |
i had to do that for alevels
the first time i ever saw a line of code was my first year of uni - 2 years ago lol and that was java oh and ive now added the starters of my image gallery to my website, found here: http://www.dancotton.co.uk/Gallery -------------------- |
|
|
Oct 9 2008, 08:00 AM
Post
#20
|
|
Knight Lieutenant Group: Clan Members Posts: 824 Thank(s): 0 Points: 218 Joined: 30-December 07 From: Brighton Member No.: 54 |
IT is bullshit, its more about how programs can be used etc rather than learning the how a computer processes data etc. I decided to drop IT after GCSE and take computer science instead, was much better. Although neither compares to the super cool subject of Geology!!!
-------------------- There are 10 types of people in this world, those who understand binary and those who don't |
|
|
Lo-Fi Version | Time is now: 5th November 2024 - 01:04 AM |